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:
2026-11-09 15:15:16 +01:00
parent f470367d89
commit 6542d804f8
3 changed files with 26 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -22,6 +22,7 @@ public static class DependencyInjection
services.AddScoped<IWorkflowRepository, WorkflowRepository>();
services.AddScoped<IDocumentRepository, DocumentRepository>();
services.AddScoped<IUserRepository, UserRepository>();
return services;
}

View File

@@ -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);
}
}