Compare commits

...

4 Commits

Author SHA1 Message Date
307c81001a Update project version to 1.4.0-beta
Updated the `DigitalData.TaskFlow.API` project version from `1.3.0-beta` to `1.4.0-beta`. This includes updates to the `FileVersion` and `AssemblyVersion` from `1.3.0.0` to `1.4.0.0`, reflecting a new release with potential new features, improvements, or fixes.
2026-11-09 16:15:17 +01:00
9c5346213e Add GetAuthorizedUsersQuery and UsersController
Introduced the `GetAuthorizedUsersQuery` feature to retrieve
authorized users, including the query, result, metadata, and
handler implementation. The handler interacts with the
`IUserRepository` to fetch user data.

Added a new `UsersController` with an `[HttpGet("authorized")]`
endpoint to expose the query via a RESTful API. The endpoint
returns appropriate HTTP status codes (`200 OK`, `401
Unauthorized`, `500 Internal Server Error`) based on the
result metadata.

Included necessary `using` directives for MediatR, ASP.NET
Core, and application features.
2026-11-09 15:59:09 +01:00
6542d804f8 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`.
2026-11-09 15:15:16 +01:00
f470367d89 Add AuthorizedUser entity and DbSet to TaskFlowDbContext
A new `DbSet` property `AuthorizedUsers` was added to the
`TaskFlowDbContext` class to represent keyless results for
authorized users procedure results.

The `OnModelCreating` method was updated to configure the
`AuthorizedUser` entity as keyless, map it to a database view,
and define the `WisagId` property mapping.

Additionally, a new `AuthorizedUser` class was introduced in
the `DigitalData.TaskFlow.Domain.ProcedureResults` namespace
with an immutable `WisagId` property.
2026-11-09 15:07:13 +01:00
8 changed files with 105 additions and 3 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

@@ -0,0 +1,22 @@
using DigitalData.TaskFlow.Application.Common.Interfaces;
using MediatR;
namespace DigitalData.TaskFlow.Application.Features.Users.Queries;
public sealed record GetAuthorizedUsersQuery : IRequest<GetAuthorizedUsersResult>;
public sealed record GetAuthorizedUsersResult(IEnumerable<GetAuthorizedUsersMeta> Meta, IEnumerable<int> Wisagids);
public sealed record GetAuthorizedUsersMeta(int? Code, string Message);
public sealed class GetAuthorizedUsersQueryHandler(IUserRepository repo) : IRequestHandler<GetAuthorizedUsersQuery, GetAuthorizedUsersResult>
{
public async Task<GetAuthorizedUsersResult> Handle(GetAuthorizedUsersQuery request, CancellationToken cancellationToken)
{
var users = await repo.GetAuthorizedAsync(cancellationToken);
return new GetAuthorizedUsersResult(
Meta: [new GetAuthorizedUsersMeta(Code: 0, Message: "OK")],
Wisagids: users.Select(x => x.WisagId));
}
}

View File

@@ -0,0 +1,6 @@
namespace DigitalData.TaskFlow.Domain.ProcedureResults;
public class AuthorizedUser
{
public int WisagId { get; init; }
}

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

@@ -23,6 +23,11 @@ public sealed class TaskFlowDbContext(DbContextOptions<TaskFlowDbContext> option
/// </summary>
public DbSet<WorkflowClosing> WorkflowClosings => Set<WorkflowClosing>();
/// <summary>
/// Gets the keyless result model used for authorized users procedure results.
/// </summary>
public DbSet<AuthorizedUser> AuthorizedUsers => Set<AuthorizedUser>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
@@ -50,5 +55,12 @@ public sealed class TaskFlowDbContext(DbContextOptions<TaskFlowDbContext> option
entity.Property(x => x.Code).HasColumnName("CODE").HasColumnType("int");
entity.Property(x => x.Result).HasColumnName("RESULT").HasColumnType("nvarchar(400)");
});
modelBuilder.Entity<AuthorizedUser>(entity =>
{
entity.HasNoKey();
entity.ToView(null);
entity.Property(x => x.WisagId).HasColumnName("wisagid").HasColumnType("int");
});
}
}

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

View File

@@ -0,0 +1,36 @@
using DigitalData.TaskFlow.Application.Features.Users.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace DigitalData.TaskFlow.API.Controllers;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
[ApiController]
[Route("api/users")]
public sealed class UsersController(ISender sender) : ControllerBase
{
/// <summary>
///
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("authorized")]
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status401Unauthorized)]
[ProducesResponseType(typeof(GetAuthorizedUsersResult), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetAuthorizedAsync(CancellationToken cancellationToken)
{
var result = await sender.Send(new GetAuthorizedUsersQuery(), cancellationToken);
var code = result.Meta.FirstOrDefault()?.Code;
return code switch
{
0 => Ok(result),
4 => Unauthorized(result),
_ => StatusCode(StatusCodes.Status500InternalServerError, result)
};
}
}

View File

@@ -10,9 +10,9 @@
<Authors>Digital Data GmbH</Authors>
<Company>Digital Data GmbH</Company>
<Product>DigitalData.TaskFlow.API</Product>
<Version>1.3.0-beta</Version>
<FileVersion>1.3.0.0</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<Version>1.4.0-beta</Version>
<FileVersion>1.4.0.0</FileVersion>
<AssemblyVersion>1.4.0.0</AssemblyVersion>
<Copyright>Copyright © 2026 Digital Data GmbH. All rights reserved.</Copyright>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>