From a5a5f1debd8166b23cdaa11bb8dba4f236b8101a Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Mon, 22 Mar 2021 11:21:37 +0430 Subject: [PATCH] #98 filtering users in recent comments --- RMuseum/Controllers/GanjoorController.cs | 3 ++- RMuseum/RMuseum.xml | 9 +++++++-- RMuseum/Services/IGanjoorService.cs | 5 +++-- RMuseum/Services/Implementation/GanjoorService.cs | 8 ++++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index 7c19bb22..c33bac02 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -503,7 +503,7 @@ namespace RMuseum.Controllers public async Task GetRecentComments([FromQuery] PagingParameterModel paging) { - var comments = await _ganjoorService.GetRecentComments(paging); + var comments = await _ganjoorService.GetRecentComments(paging, Guid.Empty, true); if (!string.IsNullOrEmpty(comments.ExceptionString)) { return BadRequest(comments.ExceptionString); @@ -810,6 +810,7 @@ namespace RMuseum.Controllers /// /// /// + /// public GanjoorController(IGanjoorService ganjoorService, IAppUserService appUserService, IHttpContextAccessor httpContextAccessor, IImageFileService imageFileService) { _ganjoorService = ganjoorService; diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 7164373e..efe3f5cc 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -871,6 +871,7 @@ + @@ -6346,11 +6347,13 @@ - + get recent comments + Guid.Empty + @@ -7247,11 +7250,13 @@ - + get recent comments + + diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index 5ba7af99..90d3bf84 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -1,7 +1,6 @@ using RMuseum.Models.Ganjoor; using RMuseum.Models.Ganjoor.ViewModels; using RMuseum.Models.GanjoorAudio.ViewModels; -using RMuseum.Models.GanjoorIntegration.ViewModels; using RSecurityBackend.Models.Generic; using System; using System.Threading.Tasks; @@ -206,8 +205,10 @@ namespace RMuseum.Services /// get recent comments /// /// + /// Guid.Empty + /// /// - Task> GetRecentComments(PagingParameterModel paging); + Task> GetRecentComments(PagingParameterModel paging, Guid filterUserId, bool onlyPublished); /// /// report a comment diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index b035a6b2..4c1ebb50 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -768,15 +768,19 @@ namespace RMuseum.Services.Implementation /// get recent comments /// /// + /// + /// /// - public async Task> GetRecentComments(PagingParameterModel paging) + public async Task> GetRecentComments(PagingParameterModel paging, Guid filterUserId, bool onlyPublished) { try { var source = from comment in _context.GanjoorComments.Include(c => c.Poem).Include(c => c.User).Include(c => c.InReplyTo).ThenInclude(r => r.User) where - comment.Status == PublishStatus.Published + ((comment.Status == PublishStatus.Published) || !onlyPublished) + && + ((filterUserId == Guid.Empty) || (filterUserId != Guid.Empty && comment.UserId == filterUserId)) orderby comment.CommentDate descending select new GanjoorCommentFullViewModel() {