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.
37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Application;
|
|
using DigitalData.UserManager.Application.Contracts;
|
|
using DigitalData.UserManager.Application.DTOs.ModuleOfUser;
|
|
using DigitalData.UserManager.Domain.Entities;
|
|
using DigitalData.UserManager.Application.Contracts.Repositories;
|
|
using DigitalData.Core.Abstraction.Application.DTO;
|
|
|
|
namespace DigitalData.UserManager.Application.Services
|
|
{
|
|
[Obsolete("Use MediatR")]
|
|
public class ModuleOfUserService : CRUDService<IModuleOfUserRepository, ModuleOfUserCreateDto, ModuleOfUserReadDto, ModuleOfUser, int>, IModuleOfUserService
|
|
{
|
|
public ModuleOfUserService(IModuleOfUserRepository repository, IMapper mapper) : base(repository, mapper)
|
|
{
|
|
}
|
|
|
|
public async Task<Result> DeleteAsyncByModuleUserId(int moduleId, int userId)
|
|
{
|
|
var mous = await _repository.ReadByModelUserIdAsync(moduleId, userId);
|
|
|
|
foreach(var mou in mous)
|
|
{
|
|
await _repository.DeleteAsync(mou);
|
|
}
|
|
|
|
return Result.Success();
|
|
}
|
|
|
|
public async Task<DataResult<IEnumerable<ModuleOfUserReadDto>>> ReadByUserAsync(string username)
|
|
{
|
|
var mous = await _repository.ReadByUserAsync(username: username);
|
|
var mous_dtos = _mapper.Map<IEnumerable<ModuleOfUserReadDto>>(mous);
|
|
return Result.Success(mous_dtos);
|
|
}
|
|
}
|
|
} |