diff --git a/DigitalData.UserManager.Application/DIExtensions.cs b/DigitalData.UserManager.Application/DIExtensions.cs index 9117124..14b23d8 100644 --- a/DigitalData.UserManager.Application/DIExtensions.cs +++ b/DigitalData.UserManager.Application/DIExtensions.cs @@ -20,7 +20,7 @@ namespace DigitalData.UserManager.Application /// The IServiceCollection to which the services will be added. /// The updated IServiceCollection. public static IServiceCollection AddUserManager(this IServiceCollection services) - where TDbContext : DbContext + where TDbContext : DbContext, IUserManagerDbContext => services .AddAutoMapper(typeof(UserMappingProfile).Assembly) .AddAutoMapper(typeof(GroupMappingProfile).Assembly) @@ -50,4 +50,4 @@ namespace DigitalData.UserManager.Application return services; } } -} +} \ No newline at end of file diff --git a/DigitalData.UserManager.Application/DTOs/Base/BaseUpdateDto.cs b/DigitalData.UserManager.Application/DTOs/Base/BaseUpdateDto.cs index 4f4a2de..dd1b3d8 100644 --- a/DigitalData.UserManager.Application/DTOs/Base/BaseUpdateDto.cs +++ b/DigitalData.UserManager.Application/DTOs/Base/BaseUpdateDto.cs @@ -1,9 +1,14 @@ -namespace DigitalData.UserManager.Application.DTOs.Base +using DigitalData.Core.Abstractions; + +namespace DigitalData.UserManager.Application.DTOs.Base { - public record BaseUpdateDto() + public record BaseUpdateDto() : IUnique { + public string ChangedWho { get; set; } = "UNAUTHORIZED"; public DateTime ChangedWhen { get; set; } = DateTime.Now; + + public int Id { get; init; } } } \ No newline at end of file diff --git a/DigitalData.UserManager.Application/DTOs/Group/GroupUpdateDto.cs b/DigitalData.UserManager.Application/DTOs/Group/GroupUpdateDto.cs index dd99e4c..b509469 100644 --- a/DigitalData.UserManager.Application/DTOs/Group/GroupUpdateDto.cs +++ b/DigitalData.UserManager.Application/DTOs/Group/GroupUpdateDto.cs @@ -4,12 +4,10 @@ namespace DigitalData.UserManager.Application.DTOs.Group { public record GroupUpdateDto ( - int Id, string? Name, bool? AdSync, bool? Internal, bool? Active, - string? Comment, - string? ChangedWho + string? Comment ) : BaseUpdateDto(); } \ No newline at end of file diff --git a/DigitalData.UserManager.Application/DTOs/GroupOfUser/GroupOfUserUpdateDto.cs b/DigitalData.UserManager.Application/DTOs/GroupOfUser/GroupOfUserUpdateDto.cs index 77a3c54..ca12ca3 100644 --- a/DigitalData.UserManager.Application/DTOs/GroupOfUser/GroupOfUserUpdateDto.cs +++ b/DigitalData.UserManager.Application/DTOs/GroupOfUser/GroupOfUserUpdateDto.cs @@ -3,7 +3,6 @@ namespace DigitalData.UserManager.Application.DTOs.GroupOfUser { public record GroupOfUserUpdateDto( - int Id, int? UserId, int? GroupId, string? Comment diff --git a/DigitalData.UserManager.Application/DTOs/Module/ModuleDto.cs b/DigitalData.UserManager.Application/DTOs/Module/ModuleDto.cs index 63da30e..7c7b6a7 100644 --- a/DigitalData.UserManager.Application/DTOs/Module/ModuleDto.cs +++ b/DigitalData.UserManager.Application/DTOs/Module/ModuleDto.cs @@ -1,8 +1,10 @@ -namespace DigitalData.UserManager.Application.DTOs.Module +using DigitalData.Core.Abstractions; + +namespace DigitalData.UserManager.Application.DTOs.Module { public record ModuleDto( int Id, string? Name, string? ShortName - ); + ) : IUnique; } \ No newline at end of file diff --git a/DigitalData.UserManager.Application/DTOs/ModuleOfUser/ModuleOfUserUpdateDto.cs b/DigitalData.UserManager.Application/DTOs/ModuleOfUser/ModuleOfUserUpdateDto.cs index 59c711c..a0e3337 100644 --- a/DigitalData.UserManager.Application/DTOs/ModuleOfUser/ModuleOfUserUpdateDto.cs +++ b/DigitalData.UserManager.Application/DTOs/ModuleOfUser/ModuleOfUserUpdateDto.cs @@ -1,4 +1,6 @@ -namespace DigitalData.UserManager.Application.DTOs.ModuleOfUser +using DigitalData.Core.Abstractions; + +namespace DigitalData.UserManager.Application.DTOs.ModuleOfUser { public record ModuleOfUserUpdateDto( int Id, @@ -7,5 +9,5 @@ bool? IsAdmin, string? Comment, string? ChangedWho - ); + ) : IUnique; } \ No newline at end of file diff --git a/DigitalData.UserManager.Application/DTOs/User/UserUpdateDto.cs b/DigitalData.UserManager.Application/DTOs/User/UserUpdateDto.cs index bbe3143..c4dd03e 100644 --- a/DigitalData.UserManager.Application/DTOs/User/UserUpdateDto.cs +++ b/DigitalData.UserManager.Application/DTOs/User/UserUpdateDto.cs @@ -3,7 +3,6 @@ namespace DigitalData.UserManager.Application.DTOs.User { public record UserUpdateDto( - int Id, string? Prename, string? Name, string? Username, @@ -13,7 +12,6 @@ namespace DigitalData.UserManager.Application.DTOs.User string? Comment, bool? Deleted, string? DateFormat, - bool? Active, - string AddedWho + bool? Active ) : BaseUpdateDto(); -} +} \ No newline at end of file diff --git a/DigitalData.UserManager.Application/Services/GroupOfUserService.cs b/DigitalData.UserManager.Application/Services/GroupOfUserService.cs index dd96b99..688be6a 100644 --- a/DigitalData.UserManager.Application/Services/GroupOfUserService.cs +++ b/DigitalData.UserManager.Application/Services/GroupOfUserService.cs @@ -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>(entities); + var gouReadDtos = _mapper.Map>(entities); return Result.Success(gouReadDtos); } @@ -66,7 +65,7 @@ namespace DigitalData.UserManager.Application.Services public async Task>> ReadByUsernameAsync(string username) { var groups = await _repository.ReadByUsernameAsync(username); - var groupDtos = _mapper.MapOrThrow>(groups); + var groupDtos = _mapper.Map>(groups); return Result.Success(groupDtos); } } diff --git a/DigitalData.UserManager.Application/Services/GroupService.cs b/DigitalData.UserManager.Application/Services/GroupService.cs index d6be011..093832d 100644 --- a/DigitalData.UserManager.Application/Services/GroupService.cs +++ b/DigitalData.UserManager.Application/Services/GroupService.cs @@ -18,7 +18,7 @@ namespace DigitalData.UserManager.Application.Services public async Task> CreateAsync(DirectoryGroupDto adGroup) { - var group = _mapper.MapOrThrow(adGroup); + var group = _mapper.Map(adGroup); //set the user var user = await GetUserAsync(); @@ -31,7 +31,7 @@ namespace DigitalData.UserManager.Application.Services if (createdGroup is null) return Result.Fail(); else - return Result.Success(KeyValueOf(createdGroup)); + return Result.Success(createdGroup.Id); } } } \ No newline at end of file diff --git a/DigitalData.UserManager.Application/Services/ModuleOfUserService.cs b/DigitalData.UserManager.Application/Services/ModuleOfUserService.cs index 10acfc5..1c3379f 100644 --- a/DigitalData.UserManager.Application/Services/ModuleOfUserService.cs +++ b/DigitalData.UserManager.Application/Services/ModuleOfUserService.cs @@ -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, IModuleOfUserService { - public ModuleOfUserService(IModuleOfUserRepository repository, IStringLocalizer 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>> ReadByUserAsync(string username) { var mous = await _repository.ReadByUserAsync(username: username); - var mous_dtos = _mapper.MapOrThrow>(mous); + var mous_dtos = _mapper.Map>(mous); return Result.Success(mous_dtos); } } diff --git a/DigitalData.UserManager.Application/Services/ModuleService.cs b/DigitalData.UserManager.Application/Services/ModuleService.cs index 01f6bbd..75a8187 100644 --- a/DigitalData.UserManager.Application/Services/ModuleService.cs +++ b/DigitalData.UserManager.Application/Services/ModuleService.cs @@ -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, IModuleService { - public ModuleService(IModuleRepository repository, IStringLocalizer localizer, IMapper mapper) : base(repository, mapper) + public ModuleService(IModuleRepository repository, IMapper mapper) : base(repository, mapper) { } } -} +} \ No newline at end of file diff --git a/DigitalData.UserManager.Application/Services/UserRepService.cs b/DigitalData.UserManager.Application/Services/UserRepService.cs index d7c1423..b25e964 100644 --- a/DigitalData.UserManager.Application/Services/UserRepService.cs +++ b/DigitalData.UserManager.Application/Services/UserRepService.cs @@ -18,7 +18,7 @@ namespace DigitalData.UserManager.Application.Services public async Task>> 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>(urs); + var urReadDTOs = _mapper.Map>(urs); return Result.Success(urReadDTOs); } } diff --git a/DigitalData.UserManager.Application/Services/UserService.cs b/DigitalData.UserManager.Application/Services/UserService.cs index 79d42e5..d6081b1 100644 --- a/DigitalData.UserManager.Application/Services/UserService.cs +++ b/DigitalData.UserManager.Application/Services/UserService.cs @@ -19,34 +19,34 @@ namespace DigitalData.UserManager.Application.Services public async Task>> ReadByModuleIdAsync(int moduleId) { var users = await _repository.ReadByModuleIdAsync(moduleId); - IEnumerable readDTOs = _mapper.MapOrThrow>(users); + IEnumerable readDTOs = _mapper.Map>(users); return Result.Success(readDTOs); } public async Task>> ReadByGroupIdAsync(int groupId) { var users = await _repository.ReadByGroupIdAsync(groupId); - IEnumerable readDTOs = _mapper.MapOrThrow>(users); + IEnumerable readDTOs = _mapper.Map>(users); return Result.Success(readDTOs); } public async Task>> ReadUnassignedByModuleIdAsync(int moduleId) { var users = await _repository.ReadUnassignedByModuleIdAsync(moduleId); - IEnumerable readDTOs = _mapper.MapOrThrow>(users); + IEnumerable readDTOs = _mapper.Map>(users); return Result.Success(readDTOs); } public async Task>> ReadUnassignedByGroupIdAsync(int groupId) { var users = await _repository.ReadUnassignedByGroupIdAsync(groupId); - IEnumerable readDTOs = _mapper.MapOrThrow>(users); + IEnumerable readDTOs = _mapper.Map>(users); return Result.Success(readDTOs); } public async Task> CreateAsync(UserPrincipalDto upDto) { - var user = _mapper.MapOrThrow(upDto); + var user = _mapper.Map(upDto); if (await HasEntity(user.Id)) return Result.Fail().Message(_localizer[Key.UserAlreadyExists]); @@ -59,7 +59,7 @@ namespace DigitalData.UserManager.Application.Services if (createdUser is null) return Result.Fail(); else - return Result.Success(KeyValueOf(createdUser)); + return Result.Success(createdUser.Id); } public async Task> ReadByUsernameAsync(string username) @@ -68,7 +68,7 @@ namespace DigitalData.UserManager.Application.Services if (user is null) return Result.Fail().Message(_localizer[Key.UserNotFoundInLocalDB]); - var userDto = _mapper.MapOrThrow(user); + var userDto = _mapper.Map(user); return Result.Success(userDto); } } diff --git a/DigitalData.UserManager.Infrastructure/Contracts/IGroupRepository.cs b/DigitalData.UserManager.Infrastructure/Contracts/IGroupRepository.cs index 9b7b123..faac8af 100644 --- a/DigitalData.UserManager.Infrastructure/Contracts/IGroupRepository.cs +++ b/DigitalData.UserManager.Infrastructure/Contracts/IGroupRepository.cs @@ -6,4 +6,4 @@ namespace DigitalData.UserManager.Infrastructure.Contracts public interface IGroupRepository : ICRUDRepository { } -} +} \ No newline at end of file diff --git a/DigitalData.UserManager.Infrastructure/Contracts/IModuleOfUserRepository.cs b/DigitalData.UserManager.Infrastructure/Contracts/IModuleOfUserRepository.cs index ed187c4..6f7412a 100644 --- a/DigitalData.UserManager.Infrastructure/Contracts/IModuleOfUserRepository.cs +++ b/DigitalData.UserManager.Infrastructure/Contracts/IModuleOfUserRepository.cs @@ -11,4 +11,4 @@ namespace DigitalData.UserManager.Infrastructure.Contracts Task> ReadByUserAsync(string username); } -} +} \ No newline at end of file diff --git a/DigitalData.UserManager.Infrastructure/Contracts/IModuleRepository.cs b/DigitalData.UserManager.Infrastructure/Contracts/IModuleRepository.cs index f0f6cb7..73dab34 100644 --- a/DigitalData.UserManager.Infrastructure/Contracts/IModuleRepository.cs +++ b/DigitalData.UserManager.Infrastructure/Contracts/IModuleRepository.cs @@ -6,4 +6,4 @@ namespace DigitalData.UserManager.Infrastructure.Contracts public interface IModuleRepository : ICRUDRepository { } -} +} \ No newline at end of file diff --git a/DigitalData.UserManager.sln b/DigitalData.UserManager.sln index f346e46..895995a 100644 --- a/DigitalData.UserManager.sln +++ b/DigitalData.UserManager.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalData.UserManager.Dom EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalData.UserManager.Application", "DigitalData.UserManager.Application\DigitalData.UserManager.Application.csproj", "{0634853C-C515-48AF-8E27-E5CBF592BCE7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalData.UserManager.NgWebUI", "DigitalData.UserManager.NgWebUI\DigitalData.UserManager.NgWebUI.csproj", "{BFBD26C1-2E95-41EC-A5CC-F334CB2309A8}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalData.UserManager.Infrastructure", "DigitalData.UserManager.Infrastructure\DigitalData.UserManager.Infrastructure.csproj", "{1DD81373-82F9-4872-95C6-888624DB1797}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DigitalData.UserManager.API", "DigitalData.UserManager.API\DigitalData.UserManager.API.csproj", "{07CCD651-647C-49F7-9715-30CEBC13710D}" @@ -27,10 +25,6 @@ Global {0634853C-C515-48AF-8E27-E5CBF592BCE7}.Debug|Any CPU.Build.0 = Debug|Any CPU {0634853C-C515-48AF-8E27-E5CBF592BCE7}.Release|Any CPU.ActiveCfg = Release|Any CPU {0634853C-C515-48AF-8E27-E5CBF592BCE7}.Release|Any CPU.Build.0 = Release|Any CPU - {BFBD26C1-2E95-41EC-A5CC-F334CB2309A8}.Debug|Any CPU.ActiveCfg = Release|Any CPU - {BFBD26C1-2E95-41EC-A5CC-F334CB2309A8}.Debug|Any CPU.Build.0 = Release|Any CPU - {BFBD26C1-2E95-41EC-A5CC-F334CB2309A8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BFBD26C1-2E95-41EC-A5CC-F334CB2309A8}.Release|Any CPU.Build.0 = Release|Any CPU {1DD81373-82F9-4872-95C6-888624DB1797}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DD81373-82F9-4872-95C6-888624DB1797}.Debug|Any CPU.Build.0 = Debug|Any CPU {1DD81373-82F9-4872-95C6-888624DB1797}.Release|Any CPU.ActiveCfg = Release|Any CPU