#98 filtering users in recent comments
This commit is contained in:
parent
0fd6f8995a
commit
a5a5f1debd
@ -503,7 +503,7 @@ namespace RMuseum.Controllers
|
||||
|
||||
public async Task<IActionResult> 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
|
||||
/// <param name="ganjoorService"></param>
|
||||
/// <param name="appUserService"></param>
|
||||
/// <param name="httpContextAccessor"></param>
|
||||
/// <param name="imageFileService"></param>
|
||||
public GanjoorController(IGanjoorService ganjoorService, IAppUserService appUserService, IHttpContextAccessor httpContextAccessor, IImageFileService imageFileService)
|
||||
{
|
||||
_ganjoorService = ganjoorService;
|
||||
|
||||
@ -871,6 +871,7 @@
|
||||
<param name="ganjoorService"></param>
|
||||
<param name="appUserService"></param>
|
||||
<param name="httpContextAccessor"></param>
|
||||
<param name="imageFileService"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ImageController.Get(System.Guid,System.String)">
|
||||
<summary>
|
||||
@ -6346,11 +6347,13 @@
|
||||
<param name="commentId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetRecentComments(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetRecentComments(RSecurityBackend.Models.Generic.PagingParameterModel,System.Guid,System.Boolean)">
|
||||
<summary>
|
||||
get recent comments
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="filterUserId">Guid.Empty</param>
|
||||
<param name="onlyPublished"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.ReportComment(System.Guid,RMuseum.Models.Ganjoor.ViewModels.GanjoorPostReportCommentViewModel)">
|
||||
@ -7247,11 +7250,13 @@
|
||||
<param name="commentId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetRecentComments(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetRecentComments(RSecurityBackend.Models.Generic.PagingParameterModel,System.Guid,System.Boolean)">
|
||||
<summary>
|
||||
get recent comments
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="filterUserId"></param>
|
||||
<param name="onlyPublished"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.ReportComment(System.Guid,RMuseum.Models.Ganjoor.ViewModels.GanjoorPostReportCommentViewModel)">
|
||||
|
||||
@ -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
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="filterUserId">Guid.Empty</param>
|
||||
/// <param name="onlyPublished"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentFullViewModel[] Items)>> GetRecentComments(PagingParameterModel paging);
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentFullViewModel[] Items)>> GetRecentComments(PagingParameterModel paging, Guid filterUserId, bool onlyPublished);
|
||||
|
||||
/// <summary>
|
||||
/// report a comment
|
||||
|
||||
@ -768,15 +768,19 @@ namespace RMuseum.Services.Implementation
|
||||
/// get recent comments
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="filterUserId"></param>
|
||||
/// <param name="onlyPublished"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentFullViewModel[] Items)>> GetRecentComments(PagingParameterModel paging)
|
||||
public async Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentFullViewModel[] Items)>> 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()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user