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

@@ -10,8 +10,8 @@ namespace DigitalData.UserManager.Application.Services
{
public class GroupService : BaseService<IGroupRepository, GroupCreateDto, GroupReadDto, Group>, IGroupService
{
private readonly IStringLocalizer<Resource> _localizer;
public GroupService(IGroupRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)
private readonly IStringLocalizer<Resource>? _localizer;
public GroupService(IGroupRepository repository, IStringLocalizer<Resource>? localizer, IMapper mapper) : base(repository, mapper)
{
_localizer = localizer;
}
@@ -25,7 +25,7 @@ namespace DigitalData.UserManager.Application.Services
group.AddedWho = user?.AddedWho ?? "UNAUTHORIZED";
if (await HasEntity(group.Id))
return Result.Fail<int>().Message(_localizer[Key.GroupAlreadyExists.ToString()]);
return Result.Fail<int>().Message(_localizer?[Key.GroupAlreadyExists].Value);
var createdGroup = await _repository.CreateAsync(group);
if (createdGroup is null)