Refactored Update*Procedure records to encapsulate update data in dedicated DTOs (e.g., UpdateActionDto, UpdateEndpointDto) via a generic Data property. Updated interfaces to be generic and modified handlers to pass only the DTO to UpdateObjectProcedure. This improves maintainability, reduces duplication, and standardizes update logic across entities.
25 lines
746 B
C#
25 lines
746 B
C#
using MediatR;
|
|
using ReC.Application.Common.Procedures.UpdateProcedure;
|
|
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
|
|
|
namespace ReC.Application.Profile.Commands;
|
|
|
|
public record UpdateProfileProcedure : IUpdateProcedure<UpdateProfileDto>
|
|
{
|
|
public long Id { get; set; }
|
|
|
|
public UpdateProfileDto Data { get; set; } = null!;
|
|
}
|
|
|
|
public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileProcedure, int>
|
|
{
|
|
public async Task<int> Handle(UpdateProfileProcedure request, CancellationToken cancel)
|
|
{
|
|
return await sender.Send(new UpdateObjectProcedure
|
|
{
|
|
Entity = "PROFILE",
|
|
Id = request.Id,
|
|
Profile = request.Data
|
|
}, cancel);
|
|
}
|
|
} |