diff options
Diffstat (limited to 'Backend')
-rw-r--r-- | Backend/Api/Api/Controllers/UserController.cs | 10 | ||||
-rw-r--r-- | Backend/Api/Api/Interfaces/IPostService.cs | 1 | ||||
-rw-r--r-- | Backend/Api/Api/Models/Location.cs | 5 | ||||
-rw-r--r-- | Backend/Api/Api/Services/PostService.cs | 16 |
4 files changed, 30 insertions, 2 deletions
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<ActionResult<List<PostSend>>> 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<PostSendPage> SearchPosts(string locid, int page = 0, int sorttype = 1, int filterdate = 1); int DateEnumToDays(int filterdate); Task<List<PostSend>> GetUsersPosts(string id); + Task<List<PostSend>> 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<List<PostSend>> UserHistory(string userid) + { + var posts = await _posts.Find(_ => true).ToListAsync(); + if (posts == null) + return null; + var tosend = new List<PostSend>(); + foreach (var post in posts) + { + if (post.views.Any(x => x.Equals(userid))) + { + var x = await postToPostSend(post); + tosend.Add(x); + } + } + return tosend; + } } } |