Files
ReC/src/ReC.Application/RecActions/Commands/CreateRecActionCommand.cs
TekH 9191ec4179 Update [Obsolete] messages to mention procedures or views
Updated [Obsolete] attribute messages across several commands,
handlers, and the mapping profile to clarify that related
procedures or views should be used instead. Added [Obsolete]
to CreateOutResCommand. No functional changes made.
2026-01-12 10:52:41 +01:00

47 lines
1.4 KiB
C#

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);
}
}