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.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstractions.Infrastructure;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.Base;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
@@ -9,6 +9,7 @@ using DigitalData.UserManager.Domain.Entities;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
[Obsolete("Use MediatR")]
|
||||
public class BaseService<TCRUDRepository, TCreateDto, TReadDto, TBaseEntity> : CRUDService<TCRUDRepository, TCreateDto, TReadDto, TBaseEntity, int>, IBaseService<TCreateDto, TReadDto, TBaseEntity>
|
||||
where TCRUDRepository : ICRUDRepository<TBaseEntity, int>
|
||||
where TCreateDto : BaseCreateDto
|
||||
@@ -25,7 +26,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
|
||||
public async Task<UserReadDto?> GetUserAsync() => _lazyUserAsync is null ? null : await _lazyUserAsync.Value;
|
||||
|
||||
public override async Task<DataResult<int>> CreateAsync(TCreateDto createDto)
|
||||
public override async Task<DataResult<TReadDto>> CreateAsync(TCreateDto createDto)
|
||||
{
|
||||
var user = await GetUserAsync();
|
||||
if(user is not null)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
|
||||
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 GroupOfUserService : BaseService<IGroupOfUserRepository, GroupOfUserCreateDto, GroupOfUserReadDto, GroupOfUser>, IGroupOfUserService
|
||||
{
|
||||
public GroupOfUserService(IGroupOfUserRepository repository, IMapper mapper) : base(repository, mapper)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.DTO;
|
||||
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;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
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)
|
||||
|
||||
@@ -7,6 +7,7 @@ using DigitalData.UserManager.Application.Contracts.Repositories;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
[Obsolete("Use MediatR")]
|
||||
public class ModuleService : BasicCRUDService<IModuleRepository, ModuleDto, Module, int>, IModuleService
|
||||
{
|
||||
public ModuleService(IModuleRepository repository, IMapper mapper) : base(repository, mapper)
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.UserRep;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Application.Contracts.Repositories;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
[Obsolete("Use MediatR")]
|
||||
public class UserRepService : BaseService<IUserRepRepository, UserRepCreateDto, UserRepReadDto, UserRep>, IUserRepService
|
||||
{
|
||||
private readonly IStringLocalizer<Resource>? _localizer;
|
||||
@@ -24,13 +25,13 @@ namespace DigitalData.UserManager.Application.Services
|
||||
return Result.Success(urReadDTOs);
|
||||
}
|
||||
|
||||
public override async Task<DataResult<int>> CreateAsync(UserRepCreateDto createDto)
|
||||
public override async Task<DataResult<UserRepReadDto>> CreateAsync(UserRepCreateDto createDto)
|
||||
// XOR control
|
||||
=> (createDto.ValidFrom is null && createDto.ValidTo is not null) || (createDto.ValidFrom is not null && createDto.ValidTo is null)
|
||||
? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer?[Key.DateRangeNotXNOR].Value)
|
||||
? Result.Fail<UserRepReadDto>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer?[Key.DateRangeNotXNOR].Value)
|
||||
//date range control
|
||||
: (createDto.ValidFrom > createDto.ValidTo)
|
||||
? Result.Fail<int>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer?[Key.InvalidDateRange].Value)
|
||||
? Result.Fail<UserRepReadDto>().Notice(LogLevel.None, Flag.DataIntegrityIssue, _localizer?[Key.InvalidDateRange].Value)
|
||||
: await base.CreateAsync(createDto);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
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 UserService : BaseService<IUserRepository, UserCreateDto, UserReadDto, User>, IUserService
|
||||
{
|
||||
private readonly IStringLocalizer<Resource>? _localizer;
|
||||
|
||||
Reference in New Issue
Block a user