From 47eade57a3259e07d7a78bb9befdf6fd4112b8f8 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 9 Feb 2026 11:58:32 +0100 Subject: [PATCH] Add generic CreateCommandHandler for create operations Introduced a generic CreateCommandHandler class implementing MediatR's IRequestHandler to handle create commands. The handler uses a generic IRepository to perform asynchronous entity creation and supports dependency injection for repository access. --- .../Common/Commands/CreateCommandHandler.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 EnvelopeGenerator.Application/Common/Commands/CreateCommandHandler.cs diff --git a/EnvelopeGenerator.Application/Common/Commands/CreateCommandHandler.cs b/EnvelopeGenerator.Application/Common/Commands/CreateCommandHandler.cs new file mode 100644 index 00000000..c1dd19a8 --- /dev/null +++ b/EnvelopeGenerator.Application/Common/Commands/CreateCommandHandler.cs @@ -0,0 +1,36 @@ +using DigitalData.Core.Abstraction.Application.Repository; +using MediatR; + +namespace EnvelopeGenerator.Application.Common.Commands; + +/// +/// +/// +/// +/// +public class CreateCommandHandler : IRequestHandler + where TCommand : class, IRequest + where TEntity : class +{ + /// + /// + /// + protected readonly IRepository Repository; + + /// + /// + /// + /// + public CreateCommandHandler(IRepository repository) + { + Repository = repository; + } + + /// + /// + /// + /// + /// + /// + public Task Handle(TCommand request, CancellationToken cancel) => Repository.CreateAsync(request, cancel); +} \ No newline at end of file