Add cancellationToken to IPermissionGrantRepository

pull/2447/head
Halil İbrahim Kalkan 6 years ago
parent dfb5841133
commit 1af300ba18

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
@ -7,8 +8,17 @@ namespace Volo.Abp.PermissionManagement
{
public interface IPermissionGrantRepository : IBasicRepository<PermissionGrant, Guid>
{
Task<PermissionGrant> FindAsync(string name, string providerName, string providerKey);
Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default
);
Task<List<PermissionGrant>> GetListAsync(string providerName, string providerKey);
Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default
);
}
}

@ -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.Domain.Repositories.EntityFrameworkCore;
@ -8,7 +9,8 @@ using Volo.Abp.EntityFrameworkCore;
namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
{
public class EfCorePermissionGrantRepository : EfCoreRepository<IPermissionManagementDbContext, PermissionGrant, Guid>, IPermissionGrantRepository
public class EfCorePermissionGrantRepository : EfCoreRepository<IPermissionManagementDbContext, PermissionGrant, Guid>,
IPermissionGrantRepository
{
public EfCorePermissionGrantRepository(IDbContextProvider<IPermissionManagementDbContext> dbContextProvider)
: base(dbContextProvider)
@ -16,23 +18,31 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
}
public async Task<PermissionGrant> FindAsync(string name, string providerName, string providerKey)
public async Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await DbSet
.FirstOrDefaultAsync(s =>
s.Name == name &&
s.ProviderName == providerName &&
s.ProviderKey == providerKey
s.ProviderKey == providerKey,
GetCancellationToken(cancellationToken)
);
}
public async Task<List<PermissionGrant>> GetListAsync(string providerName, string providerKey)
public async Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await DbSet
.Where(s =>
s.ProviderName == providerName &&
s.ProviderKey == providerKey
).ToListAsync();
).ToListAsync(GetCancellationToken(cancellationToken));
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
@ -16,23 +17,31 @@ namespace Volo.Abp.PermissionManagement.MongoDB
}
public async Task<PermissionGrant> FindAsync(string name, string providerName, string providerKey)
public async Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.FirstOrDefaultAsync(s =>
s.Name == name &&
s.ProviderName == providerName &&
s.ProviderKey == providerKey
s.ProviderKey == providerKey,
GetCancellationToken(cancellationToken)
);
}
public async Task<List<PermissionGrant>> GetListAsync(string providerName, string providerKey)
public async Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(s =>
s.ProviderName == providerName &&
s.ProviderKey == providerKey
).ToListAsync();
).ToListAsync(GetCancellationToken(cancellationToken));
}
}
}
Loading…
Cancel
Save