Add IUserRepository and implement UserRepository
Added the `IUserRepository` interface to define a method for retrieving authorized users asynchronously. Registered `IUserRepository` with its implementation `UserRepository` in the dependency injection container. Implemented `UserRepository` to execute a stored procedure and fetch authorized users using `TaskFlowDbContext`.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
using DigitalData.TaskFlow.Domain.ProcedureResults;
|
||||
|
||||
namespace DigitalData.TaskFlow.Application.Common.Interfaces;
|
||||
|
||||
public interface IUserRepository : IRepository
|
||||
{
|
||||
Task<IEnumerable<AuthorizedUser>> GetAuthorizedAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public static class DependencyInjection
|
||||
|
||||
services.AddScoped<IWorkflowRepository, WorkflowRepository>();
|
||||
services.AddScoped<IDocumentRepository, DocumentRepository>();
|
||||
services.AddScoped<IUserRepository, UserRepository>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using DigitalData.TaskFlow.Application.Common.Interfaces;
|
||||
using DigitalData.TaskFlow.Domain.ProcedureResults;
|
||||
using DigitalData.TaskFlow.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DigitalData.TaskFlow.Infrastructure.Repositories;
|
||||
|
||||
public sealed class UserRepository(TaskFlowDbContext context) : IUserRepository
|
||||
{
|
||||
public async Task<IEnumerable<AuthorizedUser>> GetAuthorizedAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return await context.AuthorizedUsers
|
||||
.FromSqlInterpolated($"EXEC [dbo].[PRCUST_F19_GET_AUTHORIZED_USERS]")
|
||||
.AsNoTracking()
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user