Remove obsolete OutRes and RecAction CQRS classes
Removed deprecated command, query, and mapping classes for OutRes and RecAction entities, including their handlers and AutoMapper profiles. These components were previously marked as obsolete and have been superseded by database procedures or views. This cleanup eliminates redundant code and enforces the use of the updated data access patterns.
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using MediatR;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Application.OutResults.Commands;
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public class CreateOutResCommand : IRequest
|
||||
{
|
||||
public required long ActionId { get; set; }
|
||||
|
||||
public short? Status { get; set; }
|
||||
|
||||
public string? Message { get; set; }
|
||||
|
||||
public string? Header { get; set; }
|
||||
|
||||
public string? Body { get; set; }
|
||||
|
||||
public string? AddedWho { get; set; }
|
||||
}
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public class CreateOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<CreateOutResCommand>
|
||||
{
|
||||
public Task Handle(CreateOutResCommand request, CancellationToken cancel)
|
||||
{
|
||||
return repo.CreateAsync(request, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using MediatR;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Application.OutResults.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the command to delete output results based on specified criteria.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Deletion can be performed by providing either an <see cref="ActionId"/> or a <see cref="ProfileId"/>.
|
||||
/// At least one of these properties must be set for the operation to proceed.
|
||||
/// </remarks>
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public record DeleteOutResCommand : IRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique identifier for the action whose output results should be deleted.
|
||||
/// </summary>
|
||||
public long? ActionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique identifier for the profile whose associated action's output results should be deleted.
|
||||
/// </summary>
|
||||
public long? ProfileId { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the execution of the <see cref="DeleteOutResCommand"/>.
|
||||
/// </summary>
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public class DeleteOutResCommandHandler(IRepository<OutRes> repo) : IRequestHandler<DeleteOutResCommand>
|
||||
{
|
||||
/// <summary>
|
||||
/// Processes the delete command by removing matching <see cref="OutRes"/> entities from the repository.
|
||||
/// </summary>
|
||||
/// <param name="request">The command containing the deletion criteria.</param>
|
||||
/// <param name="cancel">A cancellation token that can be used to cancel the work.</param>
|
||||
/// <returns>A task that represents the asynchronous delete operation.</returns>
|
||||
/// <remarks>
|
||||
/// The handler deletes records where <c>OutRes.ActionId</c> matches <see cref="DeleteOutResCommand.ActionId"/>
|
||||
/// or where the associated <c>Action.ProfileId</c> matches <see cref="DeleteOutResCommand.ProfileId"/>.
|
||||
/// </remarks>
|
||||
public Task Handle(DeleteOutResCommand request, CancellationToken cancel)
|
||||
{
|
||||
return repo.DeleteAsync(x => x.ActionId == request.ActionId || x.Action!.ProfileId == request.ProfileId, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using ReC.Application.OutResults.Commands;
|
||||
using ReC.Domain.Entities;
|
||||
using ReC.Domain.Views;
|
||||
|
||||
namespace ReC.Application.OutResults;
|
||||
|
||||
// TODO: update to inject AddedWho from the current host/user contex
|
||||
public class MappingProfiles : AutoMapper.Profile
|
||||
{
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public MappingProfiles()
|
||||
{
|
||||
CreateMap<CreateOutResCommand, OutRes>()
|
||||
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow))
|
||||
.ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API"));
|
||||
|
||||
CreateMap<CreateResultViewCommand, ResultView>()
|
||||
.ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow));
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReC.Application.Common.Dto;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Application.OutResults.Queries;
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public record ReadOutResQuery : IRequest<IEnumerable<OutResDto>>
|
||||
{
|
||||
public long? ProfileId { get; init; }
|
||||
|
||||
public long? ActionId { get; init; }
|
||||
}
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public class ReadOutResHandler(IRepository<OutRes> repo, IMapper mapper) : IRequestHandler<ReadOutResQuery, IEnumerable<OutResDto>>
|
||||
{
|
||||
public async Task<IEnumerable<OutResDto>> Handle(ReadOutResQuery request, CancellationToken cancel)
|
||||
{
|
||||
var q = repo.Query;
|
||||
|
||||
if(request.ActionId is long actionId)
|
||||
q = q.Where(res => res.ActionId == actionId);
|
||||
|
||||
if(request.ProfileId is long profileId)
|
||||
q = q.Where(res => res.Action!.ProfileId == profileId);
|
||||
|
||||
var resList = await q.ToListAsync(cancel);
|
||||
|
||||
if (resList.Count == 0)
|
||||
throw new NotFoundException();
|
||||
|
||||
return mapper.Map<IEnumerable<OutResDto>>(resList);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
using ReC.Domain.Entities;
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public record CreateRecActionCommand : IRequest
|
||||
{
|
||||
public long ProfileId { get; init; }
|
||||
|
||||
public bool Active { get; init; } = true;
|
||||
|
||||
public long? EndpointId { get; set; }
|
||||
|
||||
public string? EndpointUri { get; init; }
|
||||
|
||||
public string Type { get; init; } = null!;
|
||||
|
||||
public string? HeaderQuery { get; init; }
|
||||
|
||||
public string BodyQuery { get; init; } = null!;
|
||||
|
||||
public byte Sequence { get; set; } = 1;
|
||||
|
||||
public long? EndpointAuthId { get; set; }
|
||||
}
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public class CreateRecActionCommandHandler(ISender sender, IRepository<RecAction> repo) : IRequestHandler<CreateRecActionCommand>
|
||||
{
|
||||
public async Task Handle(CreateRecActionCommand request, CancellationToken cancel)
|
||||
{
|
||||
if(request.EndpointId is null)
|
||||
if(request.EndpointUri is string endpointUri)
|
||||
{
|
||||
var endpoint = await sender.Send(new ObtainEndpointCommand { Uri = endpointUri }, cancel);
|
||||
request.EndpointId = endpoint.Id;
|
||||
}
|
||||
else
|
||||
throw new BadRequestException("Either EndpointId or EndpointUri must be provided.");
|
||||
|
||||
await repo.CreateAsync(request, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReC.Domain.Entities;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public class DeleteRecActionsCommand : IRequest
|
||||
{
|
||||
public required long ProfileId { get; init; }
|
||||
}
|
||||
|
||||
[Obsolete("Use the related procedure or view.")]
|
||||
public class DeleteRecActionsCommandHandler(IRepository<RecAction> repo) : IRequestHandler<DeleteRecActionsCommand>
|
||||
{
|
||||
public async Task Handle(DeleteRecActionsCommand request, CancellationToken cancel)
|
||||
{
|
||||
// TODO: update DeleteAsync (in Core) to return number of deleted records
|
||||
if (!await repo.Where(act => act.ProfileId == request.ProfileId).AnyAsync(cancel))
|
||||
throw new NotFoundException();
|
||||
|
||||
await repo.DeleteAsync(act => act.ProfileId == request.ProfileId, cancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user