Add MediatR support and CreateOutResCommand handler

Integrated MediatR for command handling by modifying the
CreateOutResCommand class to implement the IRequest interface.
Added a static EmptyJson property for default JSON serialization
and updated Header and Body properties to use it. Introduced
CreateOutResCommandHandler to handle command creation using
IRepository asynchronously.
This commit is contained in:
tekh 2025-12-01 11:28:57 +01:00
parent 41d00036e4
commit 3301b35067

View File

@ -1,8 +1,10 @@
using System.Text.Json;
using DigitalData.Core.Abstraction.Application.Repository;
using MediatR;
using System.Text.Json;
namespace ReC.Application.OutResults.Commands;
public class CreateOutResCommand
public class CreateOutResCommand : IRequest
{
public static readonly string EmptyJson = JsonSerializer.Serialize(new object(), options: new()
{
@ -17,3 +19,11 @@ public class CreateOutResCommand
public string? AddedWho { get; set; }
}
public class CreateOutResCommandHandler(IRepository<CreateOutResCommand> repo) : IRequestHandler<CreateOutResCommand>
{
public Task Handle(CreateOutResCommand request, CancellationToken cancel)
{
return repo.CreateAsync(request, cancel);
}
}