32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.CleanArchitecture.Application;
|
|
using DigitalData.Core.Contracts.CultureServices;
|
|
using DigitalData.Core.Contracts.Utilities.Service;
|
|
using DigitalData.UserManager.Application.Contracts;
|
|
using DigitalData.UserManager.Application.DTOs.Group;
|
|
using DigitalData.UserManager.Domain.Entities;
|
|
using DigitalData.UserManager.Infrastructure.Contracts;
|
|
|
|
namespace DigitalData.UserManager.Application.Services
|
|
{
|
|
public class GroupService : CRUDService<IGroupRepository, GroupCreateDto, GroupReadDto, GroupUpdateDto, Group, int>, IGroupService
|
|
{
|
|
public GroupService(IGroupRepository repository, IKeyTranslationService translationService, IMapper mapper) : base(repository, translationService, mapper)
|
|
{
|
|
}
|
|
|
|
public async Task<IServiceResult<int>> CreateAsync(ADGroup adGroup)
|
|
{
|
|
var group = MapOrThrow<ADGroup, Group>(adGroup);
|
|
|
|
if (await HasEntity(group.Guid))
|
|
return Failed<int>(MessageKey.GroupAlreadyExists.ToString());
|
|
|
|
var createdGroup = await _repository.CreateAsync(group);
|
|
if (createdGroup is null)
|
|
return Failed<int>();
|
|
else
|
|
return Successful(KeyValueOf(createdGroup));
|
|
}
|
|
}
|
|
} |