refactor(Application): made IStringLocalizer<Resource>

This commit is contained in:
Developer 02
2025-01-20 14:10:31 +01:00
parent bd7d521c1e
commit 7fc71f427b
4 changed files with 12 additions and 11 deletions

View File

@@ -11,8 +11,8 @@ namespace DigitalData.UserManager.Application.Services
{
public class UserRepService : BaseService<IUserRepRepository, UserRepCreateDto, UserRepReadDto, UserRep>, IUserRepService
{
private readonly IStringLocalizer<Resource> _localizer;
public UserRepService(IUserRepRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)
private readonly IStringLocalizer<Resource>? _localizer;
public UserRepService(IUserRepRepository repository, IStringLocalizer<Resource>? localizer, IMapper mapper) : base(repository, mapper)
{
_localizer = localizer;
}
@@ -27,10 +27,10 @@ namespace DigitalData.UserManager.Application.Services
public override async Task<DataResult<int>> CreateAsync(UserRepCreateDto createDto)
// XOR control
=> (createDto.ValidFrom is null && createDto.ValidTo is not null) || (createDto.ValidFrom is not null && createDto.ValidTo is null)
? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer[Key.DateRangeNotXNOR])
? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer?[Key.DateRangeNotXNOR].Value)
//date range control
: (createDto.ValidFrom > createDto.ValidTo)
? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer[Key.InvalidDateRange])
? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer?[Key.InvalidDateRange].Value)
: await base.CreateAsync(createDto);
}
}