From 0ec823ec9ee380291a8eeec4607efd836dca9a80 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 11 Feb 2026 12:06:32 +0100 Subject: [PATCH] Add ISender extension methods for reading email templates Introduced ReadEmailTemplateQueryExtensions with methods to fetch a single EmailTemplateDto by ID or type and language code. Added required using directive for EnvelopeGenerator.Application.Common.Extensions. These extensions streamline querying email templates via ISender. --- .../Queries/ReadEmailTemplateQuery.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/EnvelopeGenerator.Application/EmailTemplates/Queries/ReadEmailTemplateQuery.cs b/EnvelopeGenerator.Application/EmailTemplates/Queries/ReadEmailTemplateQuery.cs index 11c97cfa..40604ba4 100644 --- a/EnvelopeGenerator.Application/EmailTemplates/Queries/ReadEmailTemplateQuery.cs +++ b/EnvelopeGenerator.Application/EmailTemplates/Queries/ReadEmailTemplateQuery.cs @@ -6,6 +6,7 @@ using EnvelopeGenerator.Domain.Entities; using Microsoft.EntityFrameworkCore; using EnvelopeGenerator.Domain.Constants; using DigitalData.Core.Exceptions; +using EnvelopeGenerator.Application.Common.Extensions; namespace EnvelopeGenerator.Application.EmailTemplates.Queries; @@ -41,6 +42,40 @@ public record ReadEmailTemplateQuery : IEmailTemplateQuery, IRequest +/// +/// +public static class ReadEmailTemplateQueryExtensions +{ + /// + /// + /// + /// + /// + /// + /// + /// + public static async Task ReadEmailTemplateById(this ISender sender, int id, string langCode, CancellationToken cancel = default) + { + var result = await sender.Send(new ReadEmailTemplateQuery { Id = id, LangCode = langCode }, cancel); + return result.FirstOrDefault(); + } + + /// + /// + /// + /// + /// + /// + /// + /// + public static async Task ReadEmailTemplateByType(this ISender sender, EmailTemplateType type, string langCode, CancellationToken cancel = default) + { + var result = await sender.Send(new ReadEmailTemplateQuery { Type = type, LangCode = langCode }, cancel); + return result.FirstOrDefault(); + } +} + /// /// ///