Refaktorisierung der Lokalisierung und DTO-Integration
- Ersetzung von ITranslateService durch IStringLocalizer<X> für verbesserte Lokalisierung. - Aktualisierung der DTO-Klassen entsprechend der neuesten Core.DTO-Struktur. - Integration der neuen Klassen Result und DataResult aus Core.DTO für standardisierte Serviceantworten.
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.Core.Contracts.Application;
|
||||
using DigitalData.Core.Contracts.CultureServices;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
public class GroupOfUserService : CRUDService<IGroupOfUserRepository, GroupOfUserCreateDto, GroupOfUserReadDto, GroupOfUserUpdateDto, GroupOfUser, int>, IGroupOfUserService
|
||||
{
|
||||
public GroupOfUserService(IGroupOfUserRepository repository, IKeyTranslationService translationService, IMapper mapper) : base(repository, translationService, mapper)
|
||||
public GroupOfUserService(IGroupOfUserRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, localizer, mapper)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IServiceMessage> DeleteAsyncByGroupUserId(int groupId, int userId)
|
||||
public async Task<Result> DeleteAsyncByGroupUserId(int groupId, int userId)
|
||||
{
|
||||
var mous = await _repository.ReadByGroupUserIdAsync(groupId, userId);
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace DigitalData.UserManager.Application.Services
|
||||
await _repository.DeleteAsync(mou);
|
||||
}
|
||||
|
||||
return Successful();
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
public async Task<IServiceResult<IEnumerable<GroupOfUserReadDto>>> ReadAllAsyncWith(bool user, bool group)
|
||||
public async Task<DataResult<IEnumerable<GroupOfUserReadDto>>> ReadAllAsyncWith(bool user, bool group)
|
||||
{
|
||||
IEnumerable<GroupOfUser> entities;
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace DigitalData.UserManager.Application.Services
|
||||
}
|
||||
|
||||
var gouReadDtos = _mapper.MapOrThrow<IEnumerable<GroupOfUserReadDto>>(entities);
|
||||
return Successful(gouReadDtos);
|
||||
return Result.Success(gouReadDtos);
|
||||
}
|
||||
|
||||
public async Task<IServiceMessage> HasGroup(string username, string groupname, bool caseSensitive = true)
|
||||
public async Task<Result> HasGroup(string username, string groupname, bool caseSensitive = true)
|
||||
{
|
||||
var gous = await _repository.ReadAllAsyncWithGroupAndUser();
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
else
|
||||
gous = gous.Where(gous => gous.User?.Username.ToLower() == username.ToLower() && gous.Group?.Name?.ToLower() == groupname.ToLower());
|
||||
|
||||
return CreateMessage(gous.Any());
|
||||
return gous.Any() ? Result.Success() : Result.Fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user