TekH e9527ca61e Refactor namespaces and update DTO structures
Updated namespaces for DTOs and services to improve project organization. Marked several interfaces as obsolete in favor of MediatR for better request handling. Simplified `BaseUpdateDto` and other DTOs by removing `IUnique<int>` implementation. Changed return types of `CreateAsync` methods to return corresponding read DTOs. Removed reference to `DigitalData.Core.DTO` in the project file, reflecting a shift in architecture for maintainability.
2025-06-25 17:14:24 +02:00

38 lines
1.5 KiB
C#

using AutoMapper;
using DigitalData.UserManager.Application.Contracts;
using DigitalData.UserManager.Application.DTOs.Group;
using DigitalData.UserManager.Domain.Entities;
using DigitalData.UserManager.Application.Contracts.Repositories;
using Microsoft.Extensions.Localization;
using DigitalData.Core.Abstraction.Application.DTO;
namespace DigitalData.UserManager.Application.Services
{
[Obsolete("Use MediatR")]
public class GroupService : BaseService<IGroupRepository, GroupCreateDto, GroupReadDto, Group>, IGroupService
{
private readonly IStringLocalizer<Resource>? _localizer;
public GroupService(IGroupRepository repository, IMapper mapper, IStringLocalizer<Resource>? localizer = null) : base(repository, mapper)
{
_localizer = localizer;
}
public async Task<DataResult<int>> CreateAsync(DirectoryGroupDto adGroup)
{
var group = _mapper.Map<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].Value);
var createdGroup = await _repository.CreateAsync(group);
if (createdGroup is null)
return Result.Fail<int>();
else
return Result.Success(createdGroup.Id);
}
}
}