Browse Source

code review was done

pull/19919/head
EmreKendirli 2 years ago
parent
commit
71b8e96cd2
  1. 2504
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20240522071639_Initial.Designer.cs
  2. 1409
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20240522071639_Initial.cs
  3. 2501
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  4. 2
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj
  5. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs
  6. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs
  7. 17
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Components/CommentsSetting/CommentSettingViewComponent.cs
  8. 11
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/index.js
  9. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml
  10. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml
  11. 7
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingPageContributor.cs
  12. 13
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingScriptBundleContributor.cs
  13. 18
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingViewComponent.cs
  14. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/Index.cshtml
  15. 1
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/index.js
  16. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Volo.CmsKit.Admin.Web.csproj
  17. 6
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentApproveStateType.cs
  18. 12
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs
  19. 60
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs
  20. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs

2504
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20240522071639_Initial.Designer.cs

File diff suppressed because it is too large

1409
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20240522071639_Initial.cs

File diff suppressed because it is too large

2501
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs

File diff suppressed because it is too large

2
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj

@ -6,7 +6,7 @@
<PreserveCompilationReferences>true</PreserveCompilationReferences> <PreserveCompilationReferences>true</PreserveCompilationReferences>
<UserSecretsId>Volo.CmsKit-c2d31439-b723-48e2-b061-5ebd7aeb6010</UserSecretsId> <UserSecretsId>Volo.CmsKit-c2d31439-b723-48e2-b061-5ebd7aeb6010</UserSecretsId>
<!-- Options for DB: MongoDB, EntityFrameworkCore --> <!-- Options for DB: MongoDB, EntityFrameworkCore -->
<DefineConstants>$(DefineConstants);MongoDB </DefineConstants> <DefineConstants>$(DefineConstants);MongoDB</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

6
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs

@ -114,7 +114,7 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp
} }
public async Task<int> GetPendingCommentCount() public async Task<int> GetPendingCommentCount()
{ {
var count = await CommentRepository.GetCountAsync(commentApproveStateType: CommentApproveStateType.Null); var count = await CommentRepository.GetCountAsync(commentApproveStateType: CommentApproveStateType.Waiting);
return (int)(count); return (int)(count);
} }
@ -128,7 +128,7 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp
input.Author, input.Author,
input.CreationStartDate, input.CreationStartDate,
input.CreationEndDate, input.CreationEndDate,
CommentApproveStateType.Null CommentApproveStateType.Waiting
); );
@ -142,7 +142,7 @@ public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAp
input.Sorting, input.Sorting,
input.MaxResultCount, input.MaxResultCount,
input.SkipCount, input.SkipCount,
CommentApproveStateType.Null CommentApproveStateType.Waiting
); );
var dtos = comments.Select(queryResultItem => var dtos = comments.Select(queryResultItem =>

2
modules/cms-kit/src/Volo.CmsKit.Admin.Web/CmsKitAdminWebModule.cs

@ -16,7 +16,7 @@ using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
using Volo.CmsKit.Admin.MediaDescriptors; using Volo.CmsKit.Admin.MediaDescriptors;
using Volo.CmsKit.Admin.Web.Menus; using Volo.CmsKit.Admin.Web.Menus;
using Volo.CmsKit.Admin.Web.Settings; using Volo.CmsKit.Admin.Web.Pages.CmsKit.Shared.Components.Comments;
using Volo.CmsKit.Localization; using Volo.CmsKit.Localization;
using Volo.CmsKit.Permissions; using Volo.CmsKit.Permissions;
using Volo.CmsKit.Web; using Volo.CmsKit.Web;

17
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Components/CommentsSetting/CommentSettingViewComponent.cs

@ -1,17 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
namespace Volo.CmsKit.Admin.Web.Components.MySettingGroup;
[Widget(
ScriptFiles = new[] { "/Components/CommentsSetting/index.js" }
)]
[ViewComponent(Name = "CmsKitCommentOptions")]
public class CommentSettingViewComponent: AbpViewComponent
{
public virtual IViewComponentResult Invoke()
{
return View("~/Components/CommentsSetting/Index.cshtml");
}
}

11
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Approve/index.js

@ -1,4 +1,7 @@
$(function () { 
$(function () {
var l = abp.localization.getResource("CmsKit"); var l = abp.localization.getResource("CmsKit");
var commentsService = volo.cmsKit.admin.comments.commentAdmin; var commentsService = volo.cmsKit.admin.comments.commentAdmin;
@ -81,14 +84,13 @@
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { .catch(function (error) {
console.log("error", error)
abp.notify.error(error.message); abp.notify.error(error.message);
}); });
} }
}, },
{ {
text: function (data) { text: function (data) {
return l('Revoke Approval') ; return l('Disapproved') ;
}, },
action: function (data) { action: function (data) {
var newApprovalStatus = false; var newApprovalStatus = false;
@ -101,7 +103,6 @@
abp.notify.success(message); abp.notify.success(message);
}) })
.catch(function (error) { .catch(function (error) {
console.log("error", error)
abp.notify.error(error.message); abp.notify.error(error.message);
}); });
} }
@ -138,6 +139,8 @@
data: "text", data: "text",
orderable: false, orderable: false,
render: function (data) { render: function (data) {
//var markdownData = marked(data || "");
//var sanitizedData = DOMPurify.sanitize(markdownData);
data = $.fn.dataTable.render.text().display(data || ""); data = $.fn.dataTable.render.text().display(data || "");
return ( return (

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Details.cshtml

@ -99,9 +99,9 @@
<label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label> <label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label>
<select id="isApprovedSelect" asp-for="@Model.commentApproveStateType" class="form-control"> <select id="isApprovedSelect" asp-for="@Model.commentApproveStateType" class="form-control">
<option value="@CommentApproveStateType.All">@L["CommentFilter:All"].Value</option> <option value="@CommentApproveStateType.All">@L["CommentFilter:All"].Value</option>
<option value="@CommentApproveStateType.True">@L["CommentFilter:Approved"].Value</option> <option value="@CommentApproveStateType.Approved">@L["CommentFilter:Approved"].Value</option>
<option value="@CommentApproveStateType.False">@L["CommentFilter:Disapproved"].Value</option> <option value="@CommentApproveStateType.Disapproved">@L["CommentFilter:Disapproved"].Value</option>
<option value="@CommentApproveStateType.Null">@L["CommentFilter:Waiting"].Value</option> <option value="@CommentApproveStateType.Waiting">@L["CommentFilter:Waiting"].Value</option>
</select> </select>
</div> </div>
</abp-column> </abp-column>

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml

@ -64,9 +64,9 @@
<label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label> <label class="mb-1" for="isApprovedSelect">@L["CommentFilter:ApproveState"].Value</label>
<select id="isApprovedSelect" asp-for="@Model.commentApproveStateType" class="form-control"> <select id="isApprovedSelect" asp-for="@Model.commentApproveStateType" class="form-control">
<option value="@CommentApproveStateType.All">@L["CommentFilter:All"].Value</option> <option value="@CommentApproveStateType.All">@L["CommentFilter:All"].Value</option>
<option value="@CommentApproveStateType.True">@L["CommentFilter:Approved"].Value</option> <option value="@CommentApproveStateType.Approved">@L["CommentFilter:Approved"].Value</option>
<option value="@CommentApproveStateType.False">@L["CommentFilter:Disapproved"].Value</option> <option value="@CommentApproveStateType.Disapproved">@L["CommentFilter:Disapproved"].Value</option>
<option value="@CommentApproveStateType.Null">@L["CommentFilter:Waiting"].Value</option> <option value="@CommentApproveStateType.Waiting">@L["CommentFilter:Waiting"].Value</option>
</select> </select>
</div> </div>
</abp-column> </abp-column>

7
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Settings/CommentSettingPageContributor.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingPageContributor.cs

@ -1,12 +1,10 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; using Volo.Abp.SettingManagement.Web.Pages.SettingManagement;
using Volo.CmsKit.Admin.Web.Components.MySettingGroup;
using Volo.CmsKit.Localization; using Volo.CmsKit.Localization;
namespace Volo.CmsKit.Admin.Web.Settings; namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Shared.Components.Comments;
public class CommentSettingPageContributor : ISettingPageContributor public class CommentSettingPageContributor : ISettingPageContributor
{ {
@ -31,5 +29,4 @@ public class CommentSettingPageContributor : ISettingPageContributor
// You can check the permissions here // You can check the permissions here
return Task.FromResult(true); return Task.FromResult(true);
} }
} }

13
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingScriptBundleContributor.cs

@ -0,0 +1,13 @@
using System.Collections.Generic;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Shared.Components.Comments;
public class CommentSettingScriptBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/client-proxies/cms-kit-common-proxy.js");
context.Files.AddIfNotContains("/Pages/CmsKit/Shared/Components/Comments/index.js");
}
}

18
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/CommentSettingViewComponent.cs

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
using Volo.Abp.AspNetCore.Mvc;
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Shared.Components.Comments;
[ViewComponent(Name = "CmsCommentSetting")]
[Widget(
ScriptTypes = new[] { typeof(CommentSettingScriptBundleContributor) },
// RefreshUrl = "/CmsKitPublicWidgets/Commenting",
AutoInitialize = true
)]
public class CommentSettingViewComponent : AbpViewComponent
{
public virtual IViewComponentResult Invoke()
{
return View("~/Pages/CmsKit/Shared/Components/Comments/Index.cshtml");
}
}

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Components/CommentsSetting/Index.cshtml → modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/Index.cshtml

@ -10,7 +10,7 @@
<abp-script src="/client-proxies/cms-kit-admin-proxy.js" /> <abp-script src="/client-proxies/cms-kit-admin-proxy.js" />
<abp-script src="/client-proxies/cms-kit-common-proxy.js" /> <abp-script src="/client-proxies/cms-kit-common-proxy.js" />
@* <abp-script src="" /> *@ @* <abp-script src="" /> *@
@* <script src="/Components/CommentsSetting/index.js"></script> *@ <abp-script src="/Pages/CmsKit/Shared/Components/Comments/index.js"></abp-script>
</abp-script-bundle> </abp-script-bundle>
} }
@{ @{
@ -39,6 +39,7 @@
} }
<script> <script>
var l = abp.localization.getResource("CmsKit");
var app = app || {}; var app = app || {};
app.commentAdmin = (function () { app.commentAdmin = (function () {
@ -65,7 +66,8 @@
_service.setSettings({ requireApprovement: isChecked }).done(function (response) { _service.setSettings({ requireApprovement: isChecked }).done(function (response) {
console.log('CheckBox durumu başarıyla güncellendi:', response); console.log('CheckBox durumu başarıyla güncellendi:', response);
abp.notify.success('CheckBox durumu başarıyla kaydedildi.');
abp.notify.success(l("SavedSuccessfully"));
}).fail(function (error) { }).fail(function (error) {
console.error('CheckBox durumu güncellenirken bir hata oluştu:', error); console.error('CheckBox durumu güncellenirken bir hata oluştu:', error);
abp.notify.error('CheckBox durumu kaydedilirken bir hata oluştu.'); abp.notify.error('CheckBox durumu kaydedilirken bir hata oluştu.');

1
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Components/CommentsSetting/index.js → modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Shared/Components/Comments/index.js

@ -21,6 +21,7 @@
// }); // });
// }); // });
//}); //});
console.log("dsf")
var service = volo.cmsKit.admin.comments.commentAdmin; var service = volo.cmsKit.admin.comments.commentAdmin;
$(document).ready(function () { $(document).ready(function () {

3
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Volo.CmsKit.Admin.Web.csproj

@ -24,8 +24,6 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Pages\**\*.css" /> <EmbeddedResource Include="Pages\**\*.css" />
<EmbeddedResource Include="Pages\**\*.js" /> <EmbeddedResource Include="Pages\**\*.js" />
<EmbeddedResource Include="Components\**\*.js" />
<EmbeddedResource Include="Components\**\*.css" />
<EmbeddedResource Include="wwwroot\**\*.js" /> <EmbeddedResource Include="wwwroot\**\*.js" />
<EmbeddedResource Include="wwwroot\**\*.css" /> <EmbeddedResource Include="wwwroot\**\*.css" />
<Content Remove="Pages\**\*.css" /> <Content Remove="Pages\**\*.css" />
@ -35,7 +33,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Components\CommentsSetting\Index.js" />
<None Remove="Pages\CmsKit\Comments\Approve\index.js" /> <None Remove="Pages\CmsKit\Comments\Approve\index.js" />
</ItemGroup> </ItemGroup>

6
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentApproveStateType.cs

@ -6,7 +6,7 @@ namespace Volo.CmsKit.Comments;
public enum CommentApproveStateType public enum CommentApproveStateType
{ {
All, All,
True, Approved,
False, Disapproved,
Null Waiting
} }

12
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs

@ -125,15 +125,15 @@ public class EfCoreCommentRepository : EfCoreRepository<ICmsKitDbContext, Commen
Author = user Author = user
}; };
if (CommentApproveStateType.True == commentApproveStateType) if (CommentApproveStateType.Approved == commentApproveStateType)
{ {
query = query.Where(c => c.Comment.IsApproved == true); query = query.Where(c => c.Comment.IsApproved == true);
} }
else if (CommentApproveStateType.False == commentApproveStateType) else if (CommentApproveStateType.Disapproved == commentApproveStateType)
{ {
query = query.Where(c => c.Comment.IsApproved == false); query = query.Where(c => c.Comment.IsApproved == false);
} }
else if (CommentApproveStateType.Null == commentApproveStateType) else if (CommentApproveStateType.Waiting == commentApproveStateType)
{ {
query = query.Where(c => c.Comment.IsApproved == null); query = query.Where(c => c.Comment.IsApproved == null);
} }
@ -195,9 +195,9 @@ public class EfCoreCommentRepository : EfCoreRepository<ICmsKitDbContext, Commen
.WhereIf(!authorUsername.IsNullOrWhiteSpace(), c => c.Author.UserName.Contains(authorUsername)) .WhereIf(!authorUsername.IsNullOrWhiteSpace(), c => c.Author.UserName.Contains(authorUsername))
.WhereIf(creationStartDate.HasValue, c => c.Comment.CreationTime >= creationStartDate) .WhereIf(creationStartDate.HasValue, c => c.Comment.CreationTime >= creationStartDate)
.WhereIf(creationEndDate.HasValue, c => c.Comment.CreationTime <= creationEndDate) .WhereIf(creationEndDate.HasValue, c => c.Comment.CreationTime <= creationEndDate)
.WhereIf(CommentApproveStateType.True == commentApproveStateType, c => c.Comment.IsApproved == true) .WhereIf(CommentApproveStateType.Approved == commentApproveStateType, c => c.Comment.IsApproved == true)
.WhereIf(CommentApproveStateType.False == commentApproveStateType, c => c.Comment.IsApproved == false) .WhereIf(CommentApproveStateType.Disapproved == commentApproveStateType, c => c.Comment.IsApproved == false)
.WhereIf(CommentApproveStateType.Null == commentApproveStateType, c => c.Comment.IsApproved == null); .WhereIf(CommentApproveStateType.Waiting == commentApproveStateType, c => c.Comment.IsApproved == null);
//.WhereIf(isApproved.HasValue, c => c.Comment.IsApproved == isApproved); //.WhereIf(isApproved.HasValue, c => c.Comment.IsApproved == isApproved);
} }
} }

60
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs

@ -48,9 +48,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
CommentApproveStateType commentApproveStateType = CommentApproveStateType.All, CommentApproveStateType commentApproveStateType = CommentApproveStateType.All,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
//bool? isApprovedValue = ParseIsApproved(isApproved);
var token = GetCancellationToken(cancellationToken); var token = GetCancellationToken(cancellationToken);
var query = await GetListQueryAsync( var query = await GetListQueryAsync(
@ -99,7 +97,6 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
//bool? isApprovedValue = ParseIsApproved(isApproved);
var query = await GetListQueryAsync( var query = await GetListQueryAsync(
text, text,
entityType, entityType,
@ -180,15 +177,15 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
} }
protected virtual async Task<IQueryable<Comment>> GetListQueryAsync( protected virtual async Task<IQueryable<Comment>> GetListQueryAsync(
string filter = null, string filter = null,
string entityType = null, string entityType = null,
Guid? repliedCommentId = null, Guid? repliedCommentId = null,
string authorUsername = null, string authorUsername = null,
DateTime? creationStartDate = null, DateTime? creationStartDate = null,
DateTime? creationEndDate = null, DateTime? creationEndDate = null,
CommentApproveStateType commentApproveStateType = CommentApproveStateType.All, CommentApproveStateType commentApproveStateType = CommentApproveStateType.All,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
var queryable = await GetMongoQueryableAsync(cancellationToken); var queryable = await GetMongoQueryableAsync(cancellationToken);
@ -201,42 +198,23 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
queryable = queryable.Where(x => x.CreatorId == authorId); queryable = queryable.Where(x => x.CreatorId == authorId);
} }
queryable.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) return queryable.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter))
.WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType) .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType)
.WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId)
.WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate)
.WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate)
//.WhereIf(CommentApproveStateType.True == commentApproveStateType, c => c.IsApproved == true) .WhereIf(CommentApproveStateType.Approved == commentApproveStateType, c => c.IsApproved == true)
//.WhereIf(CommentApproveStateType.False == commentApproveStateType, c => c.IsApproved == false) .WhereIf(CommentApproveStateType.Disapproved == commentApproveStateType, c => c.IsApproved == false)
//.WhereIf(CommentApproveStateType.Null == commentApproveStateType, c => c.IsApproved == null); .WhereIf(CommentApproveStateType.Waiting == commentApproveStateType, c => c.IsApproved == null);
if (CommentApproveStateType.True == commentApproveStateType)
{
queryable = queryable.Where(c => c.IsApproved == true);
}
else if (CommentApproveStateType.False == commentApproveStateType)
{
queryable = queryable.Where(c => c.IsApproved == false);
}
else if (CommentApproveStateType.Null == commentApproveStateType)
{
queryable = queryable.Where(c => c.IsApproved == null);
}
return queryable;
} }
public IQueryable<Comment> FilterCommentsByApprovalState(IQueryable<Comment> commentsQuery, CommentApproveStateType approveState) public IQueryable<Comment> FilterCommentsByApprovalState(IQueryable<Comment> commentsQuery, CommentApproveStateType approveState)
{ {
switch (approveState) switch (approveState)
{ {
case CommentApproveStateType.True: case CommentApproveStateType.Approved:
commentsQuery = commentsQuery.Where(c => c.IsApproved == true); commentsQuery = commentsQuery.Where(c => c.IsApproved == true);
break; break;
case CommentApproveStateType.False: case CommentApproveStateType.Disapproved:
commentsQuery = commentsQuery.Where(c => c.IsApproved == true || c.IsApproved == null); commentsQuery = commentsQuery.Where(c => c.IsApproved == true || c.IsApproved == null);
break; break;
} }

4
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs

@ -59,8 +59,8 @@ public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPubli
{ {
string state = await SettingManager.GetOrNullGlobalAsync(AppSettings.RequireApprovement); string state = await SettingManager.GetOrNullGlobalAsync(AppSettings.RequireApprovement);
var commentsWithAuthor = bool.Parse(state) ? var commentsWithAuthor = bool.Parse(state) ?
await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, CommentApproveStateType.True) : await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, CommentApproveStateType.Approved) :
await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, CommentApproveStateType.False); await CommentRepository.GetListWithAuthorsAsync(entityType, entityId, CommentApproveStateType.Disapproved);
return new ListResultDto<CommentWithDetailsDto>( return new ListResultDto<CommentWithDetailsDto>(

Loading…
Cancel
Save