From 3301b350675e3f51a8efcdc5368ac7690addeb7b Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 1 Dec 2025 11:28:57 +0100 Subject: [PATCH] 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. --- .../OutResults/Commands/CreateOutResCommand.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs b/src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs index 219fd9c..a235156 100644 --- a/src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs +++ b/src/ReC.Application/OutResults/Commands/CreateOutResCommand.cs @@ -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() { @@ -16,4 +18,12 @@ public class CreateOutResCommand public string Body { get; set; } = EmptyJson; public string? AddedWho { get; set; } +} + +public class CreateOutResCommandHandler(IRepository repo) : IRequestHandler +{ + public Task Handle(CreateOutResCommand request, CancellationToken cancel) + { + return repo.CreateAsync(request, cancel); + } } \ No newline at end of file