From 19150be02821c304cd40fbf4df10d64436648db3 Mon Sep 17 00:00:00 2001 From: "branislav.radivojevic" Date: Sun, 20 Nov 2022 21:36:18 +0100 Subject: tags(samo izgled),user history,viewtick on post --- Backend/Api/Api/Controllers/UserController.cs | 10 ++++++++++ Backend/Api/Api/Interfaces/IPostService.cs | 1 + Backend/Api/Api/Models/Location.cs | 5 +++-- Backend/Api/Api/Services/PostService.cs | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) (limited to 'Backend') diff --git a/Backend/Api/Api/Controllers/UserController.cs b/Backend/Api/Api/Controllers/UserController.cs index 94e4b41..1bc395f 100644 --- a/Backend/Api/Api/Controllers/UserController.cs +++ b/Backend/Api/Api/Controllers/UserController.cs @@ -64,5 +64,15 @@ namespace Api.Controllers return Ok(rez); return BadRequest(); } + [HttpGet("history")] + [Authorize(Roles = "User")] + public async Task>> ViewHistory() + { + var id = await _userService.UserIdFromJwt(); + var rez = await _postService.UserHistory(id); + if (rez != null) + return Ok(rez); + return BadRequest(); + } } } diff --git a/Backend/Api/Api/Interfaces/IPostService.cs b/Backend/Api/Api/Interfaces/IPostService.cs index fc2ae03..12a5fe8 100644 --- a/Backend/Api/Api/Interfaces/IPostService.cs +++ b/Backend/Api/Api/Interfaces/IPostService.cs @@ -18,5 +18,6 @@ namespace Api.Interfaces Task SearchPosts(string locid, int page = 0, int sorttype = 1, int filterdate = 1); int DateEnumToDays(int filterdate); Task> GetUsersPosts(string id); + Task> UserHistory(string userid); } } \ No newline at end of file diff --git a/Backend/Api/Api/Models/Location.cs b/Backend/Api/Api/Models/Location.cs index 3402f6c..b2f0aad 100644 --- a/Backend/Api/Api/Models/Location.cs +++ b/Backend/Api/Api/Models/Location.cs @@ -22,8 +22,9 @@ namespace Api.Models public enum LocationType { GRAD,ULICA,JEZERO,REKA,PLAZA,OKEAN, MORE, MOREUZ, MOST,BANJA, - PLANINA, VISORAVAN, PIRAMIDA, LIVADA, SELO, OSTRVO, POLUOSTRVO, KLISURA, ARHIPELAG, - ADA, DELTA, FJORD, GEJZIR, IZVOR, KOTLINA, MINERALNI_IZVOR, PECINA ,SUMA, VODOPAD,VULKAN + PLANINA, VISORAVAN, PIRAMIDA, LIVADA, SELO, OSTRVO, POLUOSTRVO, KLISURA, ARHIPELAG, + ADA, DELTA, FJORD, GEJZIR, IZVOR, KOTLINA, MINERALNI_IZVOR, PECINA ,SUMA, VODOPAD,VULKAN, + MUZEJ,ZAMAK,TRG,SPOMENIK,PARK,ZGRADA } public class Coords diff --git a/Backend/Api/Api/Services/PostService.cs b/Backend/Api/Api/Services/PostService.cs index 2d62f49..cc4d064 100644 --- a/Backend/Api/Api/Services/PostService.cs +++ b/Backend/Api/Api/Services/PostService.cs @@ -349,5 +349,21 @@ namespace Api.Services } return tosend; } + public async Task> UserHistory(string userid) + { + var posts = await _posts.Find(_ => true).ToListAsync(); + if (posts == null) + return null; + var tosend = new List(); + foreach (var post in posts) + { + if (post.views.Any(x => x.Equals(userid))) + { + var x = await postToPostSend(post); + tosend.Add(x); + } + } + return tosend; + } } } -- cgit v1.2.3