feat: Basis-DTOs, Service und Controller für automatische Metadatenverwaltung hinzugefügt
- Basis-DTOs für Lese-, Erstellungs- und Aktualisierungsvorgänge erstellt, um die Felder "hinzugefügt von", "hinzugefügt am", "geändert von" und "geändert am" automatisch über Middleware zu ergänzen. - Diese Basiskomponenten in die Gruppenstruktur integriert.
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.Group;
|
||||
@@ -9,7 +8,7 @@ using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
public class GroupService : CRUDService<IGroupRepository, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group, int>, IGroupService
|
||||
public class GroupService : BaseService<IGroupRepository, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group>, IGroupService
|
||||
{
|
||||
private readonly IStringLocalizer<Resource> _localizer;
|
||||
public GroupService(IGroupRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper) : base(repository, mapper)
|
||||
@@ -17,15 +16,14 @@ namespace DigitalData.UserManager.Application.Services
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public override Task<DataResult<int>> CreateAsync(GroupCreateDto createDto)
|
||||
{
|
||||
return base.CreateAsync(createDto);
|
||||
}
|
||||
|
||||
public async Task<DataResult<int>> CreateAsync(DirectoryGroupDto adGroup)
|
||||
{
|
||||
var group = _mapper.MapOrThrow<Group>(adGroup);
|
||||
|
||||
//set the user
|
||||
var user = await GetUserAsync();
|
||||
group.AddedWho = user?.AddedWho ?? "UNAUTHORIZED";
|
||||
|
||||
if (await HasEntity(group.Id))
|
||||
return Result.Fail<int>().Message(_localizer[Key.GroupAlreadyExists.ToString()]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user