From 064704669b9b84f326aa86e65df95366504f8876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 15 Aug 2020 13:32:08 +0300 Subject: [PATCH] Add cancellationtoken to the repositories. --- .../CmsKit/Reactions/IUserReactionRepository.cs | 10 +++++++--- .../Reactions/EfCoreUserReactionRepository.cs | 16 ++++++++++------ .../Reactions/MongoUserReactionRepository.cs | 16 ++++++++++------ .../MongoDB/Users/MongoCmsUserRepository.cs | 1 - 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs index ae9398e2d0..dbbcd0ac29 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/IUserReactionRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; using Volo.Abp.Domain.Repositories; @@ -12,18 +13,21 @@ namespace Volo.CmsKit.Reactions Guid userId, [NotNull] string entityType, [NotNull] string entityId, - [NotNull] string reactionName + [NotNull] string reactionName, + CancellationToken cancellationToken = default ); Task> GetListForUserAsync( Guid userId, [NotNull] string entityType, - [NotNull] string entityId + [NotNull] string entityId, + CancellationToken cancellationToken = default ); Task> GetSummariesAsync( [NotNull] string entityType, - [NotNull] string entityId + [NotNull] string entityId, + CancellationToken cancellationToken = default ); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs index 2d0b8ba989..da89de4c74 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Volo.Abp; @@ -22,7 +23,8 @@ namespace Volo.CmsKit.Reactions Guid userId, string entityType, string entityId, - string reactionName) + string reactionName, + CancellationToken cancellationToken = default) { Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); @@ -34,13 +36,14 @@ namespace Volo.CmsKit.Reactions x.EntityType == entityType && x.EntityId == entityId && x.ReactionName == reactionName) - .FirstOrDefaultAsync(); + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } public async Task> GetListForUserAsync( Guid userId, string entityType, - string entityId) + string entityId, + CancellationToken cancellationToken = default) { Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); @@ -50,12 +53,13 @@ namespace Volo.CmsKit.Reactions x.CreatorId == userId && x.EntityType == entityType && x.EntityId == entityId) - .ToListAsync(); + .ToListAsync(GetCancellationToken(cancellationToken)); } public async Task> GetSummariesAsync( string entityType, - string entityId) + string entityId, + CancellationToken cancellationToken = default) { Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); @@ -70,7 +74,7 @@ namespace Volo.CmsKit.Reactions ReactionName = g.Key, Count = g.Count() }) - .ToListAsync(); + .ToListAsync(GetCancellationToken(cancellationToken)); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs index ae3b28766a..e3a09c4514 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using MongoDB.Driver; using MongoDB.Driver.Linq; @@ -21,7 +22,8 @@ namespace Volo.CmsKit.MongoDB.Reactions Guid userId, string entityType, string entityId, - string reactionName) + string reactionName, + CancellationToken cancellationToken = default) { Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); @@ -33,13 +35,14 @@ namespace Volo.CmsKit.MongoDB.Reactions x.EntityType == entityType && x.EntityId == entityId && x.ReactionName == reactionName) - .FirstOrDefaultAsync(); + .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } public async Task> GetListForUserAsync( Guid userId, string entityType, - string entityId) + string entityId, + CancellationToken cancellationToken = default) { Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); @@ -49,12 +52,13 @@ namespace Volo.CmsKit.MongoDB.Reactions x.CreatorId == userId && x.EntityType == entityType && x.EntityId == entityId) - .ToListAsync(); + .ToListAsync(GetCancellationToken(cancellationToken)); } public async Task> GetSummariesAsync( string entityType, - string entityId) + string entityId, + CancellationToken cancellationToken = default) { Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); @@ -69,7 +73,7 @@ namespace Volo.CmsKit.MongoDB.Reactions ReactionName = g.Key, Count = g.Count() }) - .ToListAsync(); + .ToListAsync(GetCancellationToken(cancellationToken)); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs index ed2691a5a8..22012e48c0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Users/MongoCmsUserRepository.cs @@ -10,6 +10,5 @@ namespace Volo.CmsKit.MongoDB.Users : base(dbContextProvider) { } - } }