Browse Source

added author username filter to commits

pull/7757/head
Ahmet 6 years ago
parent
commit
9fea961c52
  1. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs
  2. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs
  3. 4
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs
  4. 27
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs
  5. 27
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs

@ -13,7 +13,7 @@ namespace Volo.CmsKit.Admin.Comments
public Guid? RepliedCommentId { get; set; }
public Guid? CreatorId { get; set; }
public string AuthorUserName { get; set; }
public DateTime? CreationStartDate { get; set; }

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

@ -30,7 +30,7 @@ namespace Volo.CmsKit.Admin.Comments
input.EntityType,
input.EntityId,
input.RepliedCommentId,
input.CreatorId,
input.AuthorUserName,
input.CreationStartDate,
input.CreationEndDate);
@ -39,7 +39,7 @@ namespace Volo.CmsKit.Admin.Comments
input.EntityType,
input.EntityId,
input.RepliedCommentId,
input.CreatorId,
input.AuthorUserName,
input.CreationStartDate,
input.CreationEndDate,
input.Sorting,

4
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs

@ -16,7 +16,7 @@ namespace Volo.CmsKit.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
string sorting = null,
@ -30,7 +30,7 @@ namespace Volo.CmsKit.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
CancellationToken cancellationToken = default

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

@ -48,7 +48,7 @@ namespace Volo.CmsKit.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
string sorting = null,
@ -61,8 +61,8 @@ namespace Volo.CmsKit.Comments
filter,
entityType,
entityId,
repliedCommentId,
creatorId,
repliedCommentId,
authorUsername,
creationStartDate,
creationEndDate);
@ -86,7 +86,7 @@ namespace Volo.CmsKit.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
CancellationToken cancellationToken = default
@ -97,7 +97,7 @@ namespace Volo.CmsKit.Comments
entityType,
entityId,
repliedCommentId,
creatorId,
authorUsername,
creationStartDate,
creationEndDate);
@ -149,17 +149,28 @@ namespace Volo.CmsKit.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null
)
{
return (await GetDbSetAsync())
var dbSet = await GetDbSetAsync();
var queryable = dbSet.AsQueryable();
if (string.IsNullOrEmpty(authorUsername))
{
var author = await (await GetDbContextAsync()).User.FirstOrDefaultAsync(x => x.UserName == authorUsername);
var authorId = author?.Id ?? Guid.Empty;
queryable.Where(x => x.CreatorId == authorId);
}
return (dbSet)
.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter))
.WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType.Contains(entityType))
.WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId.Contains(entityId))
.WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId)
.WhereIf(creatorId.HasValue, c => c.CreatorId == creatorId)
.WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate)
.WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate);
}

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

@ -47,7 +47,7 @@ namespace Volo.CmsKit.MongoDB.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
string sorting = null,
@ -61,7 +61,7 @@ namespace Volo.CmsKit.MongoDB.Comments
entityType,
entityId,
repliedCommentId,
creatorId,
authorUsername,
creationStartDate,
creationEndDate,
cancellationToken);
@ -96,7 +96,7 @@ namespace Volo.CmsKit.MongoDB.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
CancellationToken cancellationToken = default
@ -107,7 +107,7 @@ namespace Volo.CmsKit.MongoDB.Comments
entityType,
entityId,
repliedCommentId,
creatorId,
authorUsername,
creationStartDate,
creationEndDate,
cancellationToken);
@ -174,18 +174,29 @@ namespace Volo.CmsKit.MongoDB.Comments
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? creatorId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
CancellationToken cancellationToken = default
)
{
return (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter))
var queryable = await GetMongoQueryableAsync(cancellationToken);
if (string.IsNullOrEmpty(authorUsername))
{
var authorQuerable = (await GetDbContextAsync(cancellationToken)).Collection<CmsUser>().AsQueryable();
var author = await authorQuerable.FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken);
var authorId = author?.Id ?? Guid.Empty;
queryable.Where(x => x.CreatorId == authorId);
}
return queryable.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter))
.WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType)
.WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId == entityId)
.WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId)
.WhereIf(creatorId.HasValue, c => c.CreatorId == creatorId)
.WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate)
.WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate);
}

Loading…
Cancel
Save