| | | 1 | | using Elsa.Identity.Contracts; |
| | | 2 | | using Elsa.Identity.Entities; |
| | | 3 | | using Elsa.Identity.Models; |
| | | 4 | | using Open.Linq.AsyncExtensions; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Persistence.EFCore.Modules.Identity; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// An EF Core implementation of <see cref="IRoleStore"/>. |
| | | 10 | | /// </summary> |
| | | 11 | | public class EFCoreRoleStore : IRoleStore |
| | | 12 | | { |
| | | 13 | | private readonly EntityStore<IdentityElsaDbContext, Role> _applicationStore; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Initializes a new instance of <see cref="EFCoreRoleStore"/>. |
| | | 17 | | /// </summary> |
| | 1 | 18 | | public EFCoreRoleStore(EntityStore<IdentityElsaDbContext, Role> applicationStore) |
| | | 19 | | { |
| | 1 | 20 | | _applicationStore = applicationStore; |
| | 1 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public async Task SaveAsync(Role application, CancellationToken cancellationToken = default) |
| | | 25 | | { |
| | 0 | 26 | | await _applicationStore.SaveAsync(application, cancellationToken); |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | public async Task AddAsync(Role role, CancellationToken cancellationToken = default) |
| | | 31 | | { |
| | 0 | 32 | | await _applicationStore.AddAsync(role, cancellationToken); |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <inheritdoc /> |
| | | 36 | | public async Task DeleteAsync(RoleFilter filter, CancellationToken cancellationToken = default) |
| | | 37 | | { |
| | 0 | 38 | | await _applicationStore.DeleteWhereAsync(query => Filter(query, filter), cancellationToken); |
| | 0 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <inheritdoc /> |
| | | 42 | | public async Task<Role?> FindAsync(RoleFilter filter, CancellationToken cancellationToken = default) |
| | | 43 | | { |
| | 0 | 44 | | return await _applicationStore.FindAsync(query => Filter(query, filter), cancellationToken); |
| | 0 | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <inheritdoc /> |
| | | 48 | | public async Task<IEnumerable<Role>> FindManyAsync(RoleFilter filter, CancellationToken cancellationToken = default) |
| | | 49 | | { |
| | 0 | 50 | | return await _applicationStore.QueryAsync(queryable => Filter(queryable, filter), cancellationToken).ToList(); |
| | 0 | 51 | | } |
| | | 52 | | |
| | 0 | 53 | | private static IQueryable<Role> Filter(IQueryable<Role> query, RoleFilter filter) => filter.Apply(query); |
| | | 54 | | } |