From 872878b9d710683a059185bb34f15723fddc6897 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 16 Jan 2026 10:36:43 +0100 Subject: [PATCH] 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. --- .../Commands/CreateOutResCommand.cs | 30 ------------ .../Commands/DeleteOutResCommand.cs | 48 ------------------- .../OutResults/MappingProfiles.cs | 20 -------- .../OutResults/Queries/ReadOutResQuery.cs | 39 --------------- .../Commands/CreateRecActionCommand.cs | 47 ------------------ .../Commands/DeleteRecActionsCommand.cs | 26 ---------- 6 files changed, 210 deletions(-) delete mode 100644 src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs delete mode 100644 src/ReC.Application/OutResults/Commands/DeleteOutResCommand.cs delete mode 100644 src/ReC.Application/OutResults/MappingProfiles.cs delete mode 100644 src/ReC.Application/OutResults/Queries/ReadOutResQuery.cs delete mode 100644 src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs delete mode 100644 src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs diff --git a/src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs b/src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs deleted file mode 100644 index 6b42ea9..0000000 --- a/src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs +++ /dev/null @@ -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 repo) : IRequestHandler -{ - public Task Handle(CreateOutResCommand request, CancellationToken cancel) - { - return repo.CreateAsync(request, cancel); - } -} \ No newline at end of file diff --git a/src/ReC.Application/OutResults/Commands/DeleteOutResCommand.cs b/src/ReC.Application/OutResults/Commands/DeleteOutResCommand.cs deleted file mode 100644 index 838357b..0000000 --- a/src/ReC.Application/OutResults/Commands/DeleteOutResCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -using DigitalData.Core.Abstraction.Application.Repository; -using MediatR; -using ReC.Domain.Entities; - -namespace ReC.Application.OutResults.Commands; - -/// -/// Represents the command to delete output results based on specified criteria. -/// -/// -/// Deletion can be performed by providing either an or a . -/// At least one of these properties must be set for the operation to proceed. -/// -[Obsolete("Use the related procedure or view.")] -public record DeleteOutResCommand : IRequest -{ - /// - /// Gets the unique identifier for the action whose output results should be deleted. - /// - public long? ActionId { get; init; } - - /// - /// Gets the unique identifier for the profile whose associated action's output results should be deleted. - /// - public long? ProfileId { get; init; } -} - -/// -/// Handles the execution of the . -/// -[Obsolete("Use the related procedure or view.")] -public class DeleteOutResCommandHandler(IRepository repo) : IRequestHandler -{ - /// - /// Processes the delete command by removing matching entities from the repository. - /// - /// The command containing the deletion criteria. - /// A cancellation token that can be used to cancel the work. - /// A task that represents the asynchronous delete operation. - /// - /// The handler deletes records where OutRes.ActionId matches - /// or where the associated Action.ProfileId matches . - /// - public Task Handle(DeleteOutResCommand request, CancellationToken cancel) - { - return repo.DeleteAsync(x => x.ActionId == request.ActionId || x.Action!.ProfileId == request.ProfileId, cancel); - } -} \ No newline at end of file diff --git a/src/ReC.Application/OutResults/MappingProfiles.cs b/src/ReC.Application/OutResults/MappingProfiles.cs deleted file mode 100644 index 6659fba..0000000 --- a/src/ReC.Application/OutResults/MappingProfiles.cs +++ /dev/null @@ -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() - .ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow)) - .ForMember(e => e.AddedWho, exp => exp.MapFrom(cmd => "ReC.API")); - - CreateMap() - .ForMember(e => e.AddedWhen, exp => exp.MapFrom(cmd => DateTime.UtcNow)); - } -} \ No newline at end of file diff --git a/src/ReC.Application/OutResults/Queries/ReadOutResQuery.cs b/src/ReC.Application/OutResults/Queries/ReadOutResQuery.cs deleted file mode 100644 index 33da8b2..0000000 --- a/src/ReC.Application/OutResults/Queries/ReadOutResQuery.cs +++ /dev/null @@ -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> -{ - public long? ProfileId { get; init; } - - public long? ActionId { get; init; } -} - -[Obsolete("Use the related procedure or view.")] -public class ReadOutResHandler(IRepository repo, IMapper mapper) : IRequestHandler> -{ - public async Task> 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>(resList); - } -} \ No newline at end of file diff --git a/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs deleted file mode 100644 index 603fbe1..0000000 --- a/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs +++ /dev/null @@ -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 repo) : IRequestHandler -{ - 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); - } -} \ No newline at end of file diff --git a/src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs b/src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs deleted file mode 100644 index 55c1c39..0000000 --- a/src/ReC.Application/RecActions/Commands/DeleteRecActionsCommand.cs +++ /dev/null @@ -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 repo) : IRequestHandler -{ - 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); - } -} \ No newline at end of file