refactor(core): DTOs und Services an Core 2.0.0.0 angepasst
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
|
||||
@@ -47,7 +46,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
entities = await _repository.ReadAllAsync();
|
||||
}
|
||||
|
||||
var gouReadDtos = _mapper.MapOrThrow<IEnumerable<GroupOfUserReadDto>>(entities);
|
||||
var gouReadDtos = _mapper.Map<IEnumerable<GroupOfUserReadDto>>(entities);
|
||||
return Result.Success(gouReadDtos);
|
||||
}
|
||||
|
||||
@@ -66,7 +65,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
public async Task<DataResult<IEnumerable<GroupOfUserReadDto>>> ReadByUsernameAsync(string username)
|
||||
{
|
||||
var groups = await _repository.ReadByUsernameAsync(username);
|
||||
var groupDtos = _mapper.MapOrThrow<IEnumerable<GroupOfUserReadDto>>(groups);
|
||||
var groupDtos = _mapper.Map<IEnumerable<GroupOfUserReadDto>>(groups);
|
||||
return Result.Success(groupDtos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
|
||||
public async Task<DataResult<int>> CreateAsync(DirectoryGroupDto adGroup)
|
||||
{
|
||||
var group = _mapper.MapOrThrow<Group>(adGroup);
|
||||
var group = _mapper.Map<Group>(adGroup);
|
||||
|
||||
//set the user
|
||||
var user = await GetUserAsync();
|
||||
@@ -31,7 +31,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
if (createdGroup is null)
|
||||
return Result.Fail<int>();
|
||||
else
|
||||
return Result.Success(KeyValueOf(createdGroup));
|
||||
return Result.Success(createdGroup.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,12 @@ using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.ModuleOfUser;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
public class ModuleOfUserService : CRUDService<IModuleOfUserRepository, ModuleOfUserCreateDto, ModuleOfUserReadDto, ModuleOfUserUpdateDto, ModuleOfUser, int>, IModuleOfUserService
|
||||
{
|
||||
public ModuleOfUserService(IModuleOfUserRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)
|
||||
public ModuleOfUserService(IModuleOfUserRepository repository, IMapper mapper) : base(repository, mapper)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,7 +29,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
public async Task<DataResult<IEnumerable<ModuleOfUserReadDto>>> ReadByUserAsync(string username)
|
||||
{
|
||||
var mous = await _repository.ReadByUserAsync(username: username);
|
||||
var mous_dtos = _mapper.MapOrThrow<IEnumerable<ModuleOfUserReadDto>>(mous);
|
||||
var mous_dtos = _mapper.Map<IEnumerable<ModuleOfUserReadDto>>(mous);
|
||||
return Result.Success(mous_dtos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.Module;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Infrastructure.Contracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
public class ModuleService : BasicCRUDService<IModuleRepository, ModuleDto, Module, int>, IModuleService
|
||||
{
|
||||
public ModuleService(IModuleRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)
|
||||
public ModuleService(IModuleRepository repository, IMapper mapper) : base(repository, mapper)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
public async Task<DataResult<IEnumerable<UserRepReadDto>>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
|
||||
{
|
||||
var urs = await _repository.ReadAllAsync(withUser, withRepGroup, withGroup, withRepUser, userId, groupId);
|
||||
var urReadDTOs = _mapper.MapOrThrow<IEnumerable<UserRepReadDto>>(urs);
|
||||
var urReadDTOs = _mapper.Map<IEnumerable<UserRepReadDto>>(urs);
|
||||
return Result.Success(urReadDTOs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,34 +19,34 @@ namespace DigitalData.UserManager.Application.Services
|
||||
public async Task<DataResult<IEnumerable<UserReadDto>>> ReadByModuleIdAsync(int moduleId)
|
||||
{
|
||||
var users = await _repository.ReadByModuleIdAsync(moduleId);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.MapOrThrow<IEnumerable<UserReadDto>>(users);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.Map<IEnumerable<UserReadDto>>(users);
|
||||
return Result.Success(readDTOs);
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<UserReadDto>>> ReadByGroupIdAsync(int groupId)
|
||||
{
|
||||
var users = await _repository.ReadByGroupIdAsync(groupId);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.MapOrThrow<IEnumerable<UserReadDto>>(users);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.Map<IEnumerable<UserReadDto>>(users);
|
||||
return Result.Success(readDTOs);
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<UserReadDto>>> ReadUnassignedByModuleIdAsync(int moduleId)
|
||||
{
|
||||
var users = await _repository.ReadUnassignedByModuleIdAsync(moduleId);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.MapOrThrow<IEnumerable<UserReadDto>>(users);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.Map<IEnumerable<UserReadDto>>(users);
|
||||
return Result.Success(readDTOs);
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<UserReadDto>>> ReadUnassignedByGroupIdAsync(int groupId)
|
||||
{
|
||||
var users = await _repository.ReadUnassignedByGroupIdAsync(groupId);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.MapOrThrow<IEnumerable<UserReadDto>>(users);
|
||||
IEnumerable<UserReadDto> readDTOs = _mapper.Map<IEnumerable<UserReadDto>>(users);
|
||||
return Result.Success(readDTOs);
|
||||
}
|
||||
|
||||
public async Task<DataResult<int>> CreateAsync(UserPrincipalDto upDto)
|
||||
{
|
||||
var user = _mapper.MapOrThrow<User>(upDto);
|
||||
var user = _mapper.Map<User>(upDto);
|
||||
|
||||
if (await HasEntity(user.Id))
|
||||
return Result.Fail<int>().Message(_localizer[Key.UserAlreadyExists]);
|
||||
@@ -59,7 +59,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
if (createdUser is null)
|
||||
return Result.Fail<int>();
|
||||
else
|
||||
return Result.Success(KeyValueOf(createdUser));
|
||||
return Result.Success(createdUser.Id);
|
||||
}
|
||||
|
||||
public async Task<DataResult<UserReadDto>> ReadByUsernameAsync(string username)
|
||||
@@ -68,7 +68,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
if (user is null)
|
||||
return Result.Fail<UserReadDto>().Message(_localizer[Key.UserNotFoundInLocalDB]);
|
||||
|
||||
var userDto = _mapper.MapOrThrow<UserReadDto>(user);
|
||||
var userDto = _mapper.Map<UserReadDto>(user);
|
||||
return Result.Success(userDto);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user