Browse Source

Refactor EfCoreUserReactionRepository

pull/4809/head
Halil İbrahim Kalkan 6 years ago
parent
commit
a32b4fbb0d
  1. 9
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs
  2. 20
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs

9
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs

@ -14,8 +14,13 @@ namespace Volo.CmsKit.Reactions
[NotNull] string entityId,
[NotNull] string reactionName);
Task<List<UserReaction>> GetListForUserAsync(Guid userId, string entityType, string entityId);
Task<List<UserReaction>> GetListForUserAsync(
Guid userId,
[NotNull] string entityType,
[NotNull] string entityId);
Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(string entityType, string entityId);
Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(
[NotNull] string entityType,
[NotNull] string entityId);
}
}

20
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
@ -23,6 +24,10 @@ namespace Volo.CmsKit.Reactions
string entityId,
string reactionName)
{
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName));
return await DbSet
.Where(x =>
x.UserId == userId &&
@ -32,8 +37,14 @@ namespace Volo.CmsKit.Reactions
.FirstOrDefaultAsync();
}
public async Task<List<UserReaction>> GetListForUserAsync(Guid userId, string entityType, string entityId)
public async Task<List<UserReaction>> GetListForUserAsync(
Guid userId,
string entityType,
string entityId)
{
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
return await DbSet
.Where(x =>
x.UserId == userId &&
@ -42,8 +53,13 @@ namespace Volo.CmsKit.Reactions
.ToListAsync();
}
public async Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(string entityType, string entityId)
public async Task<List<ReactionSummaryQueryResultItem>> GetSummariesAsync(
string entityType,
string entityId)
{
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
return await DbSet
.Where(x =>
x.EntityType == entityType &&

Loading…
Cancel
Save