chore: aktualisierte DigitalData.Core-Pakete

This commit is contained in:
Developer 02
2025-03-24 14:17:23 +01:00
parent 59e8c6c0c6
commit a142196d87
14 changed files with 628 additions and 640 deletions

View File

@@ -7,41 +7,40 @@ using DigitalData.UserManager.Domain.Entities;
using Microsoft.AspNetCore.Authorization;
using System.Security.Claims;
namespace DigitalData.UserManager.API.Controllers
namespace DigitalData.UserManager.API.Controllers;
[Authorize]
public class BaseAuthController<TCRUDService, TCreateDto, TReadDto, TUpdateDto, TBaseEntity> : CRUDControllerBaseWithErrorHandling<TCRUDService, TCreateDto, TReadDto, TUpdateDto, TBaseEntity, int>
where TCRUDService : IBaseService<TCreateDto, TReadDto, TBaseEntity>
where TCreateDto : BaseCreateDto
where TReadDto : class
where TUpdateDto : BaseUpdateDto
where TBaseEntity : BaseEntity
{
[Authorize]
public class BaseAuthController<TCRUDService, TCreateDto, TReadDto, TUpdateDto, TBaseEntity> : CRUDControllerBaseWithErrorHandling<TCRUDService, TCreateDto, TReadDto, TUpdateDto, TBaseEntity, int>
where TCRUDService : IBaseService<TCreateDto, TReadDto, TUpdateDto, TBaseEntity>
where TCreateDto : BaseCreateDto
where TReadDto : class
where TUpdateDto : BaseUpdateDto
where TBaseEntity : BaseEntity
private readonly Lazy<int?> _lUserId;
public BaseAuthController(ILogger logger, TCRUDService service, IUserService userService) : base(logger, service)
{
private readonly Lazy<int?> _lUserId;
public BaseAuthController(ILogger logger, TCRUDService service, IUserService userService) : base(logger, service)
_lUserId = new(() =>
{
_lUserId = new(() =>
{
var idSt = User.FindFirstValue(ClaimTypes.NameIdentifier);
bool hasId = int.TryParse(idSt, out int id);
return hasId ? id : null;
});
var idSt = User.FindFirstValue(ClaimTypes.NameIdentifier);
bool hasId = int.TryParse(idSt, out int id);
return hasId ? id : null;
});
service.UserFactoryAsync = async () =>
{
var id = _lUserId.Value;
service.UserFactoryAsync = async () =>
{
var id = _lUserId.Value;
return id is int intId
? await userService.ReadByIdAsync(intId).ThenAsync(
Success: res => res,
Fail: UserReadDto? (m, n) =>
{
_logger.LogNotice(n);
return null;
})
: null;
};
}
return id is int intId
? await userService.ReadByIdAsync(intId).ThenAsync(
Success: res => res,
Fail: UserReadDto? (m, n) =>
{
_logger.LogNotice(n);
return null;
})
: null;
};
}
}