From 9d45082bfcd385b585a2cc19cca794104ffdcd63 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 27 Jun 2025 13:11:40 +0200 Subject: [PATCH] Refactor TestEmailTemplateController and update namespaces - Updated `using` directives to include new namespaces. - Marked `TestEmailTemplateController` as obsolete with a suggestion to use MediatR. - Simplified the constructor by removing an empty block. - Modified `GetAll` method to include `[HttpGet]` and `[Obsolete]` attributes while retaining functionality. - Added a non-action `GetAll` method that overrides the base implementation. --- .../Test/TestEmailTemplateController.cs | 47 ++++++++++--------- .../Test/TestEnvelopeCertificateController.cs | 10 ++-- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestEmailTemplateController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestEmailTemplateController.cs index c08c0714..38abcd4f 100644 --- a/EnvelopeGenerator.Web/Controllers/Test/TestEmailTemplateController.cs +++ b/EnvelopeGenerator.Web/Controllers/Test/TestEmailTemplateController.cs @@ -1,33 +1,34 @@ -using DigitalData.Core.DTO; +using DigitalData.Core.Abstraction.Application.DTO; using EnvelopeGenerator.Application.Contracts.Services; using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; using Microsoft.AspNetCore.Mvc; -using static EnvelopeGenerator.CommonServices.Constants; +using static EnvelopeGenerator.Domain.Constants; -namespace EnvelopeGenerator.Web.Controllers.Test +namespace EnvelopeGenerator.Web.Controllers.Test; + +[Obsolete("Use MediatR")] +public class TestEmailTemplateController : TestControllerBase { - public class TestEmailTemplateController : TestControllerBase + public TestEmailTemplateController(ILogger logger, IEmailTemplateService service) : base(logger, service) { - public TestEmailTemplateController(ILogger logger, IEmailTemplateService service) : base(logger, service) - { - } - - [HttpGet] - public virtual async Task GetAll([FromQuery] string? tempType = null) - { - return tempType is null - ? await base.GetAll() - : await _service.ReadByNameAsync((EmailTemplateType)Enum.Parse(typeof(EmailTemplateType), tempType)).ThenAsync( - Success: Ok, - Fail: IActionResult (messages, notices) => - { - _logger.LogNotice(notices); - return NotFound(messages); - }); - } + } - [NonAction] - public override Task GetAll() => base.GetAll(); + [HttpGet] + [Obsolete("Use MediatR")] + public virtual async Task GetAll([FromQuery] string? tempType = null) + { + return tempType is null + ? await base.GetAll() + : await _service.ReadByNameAsync((EmailTemplateType)Enum.Parse(typeof(EmailTemplateType), tempType)).ThenAsync( + Success: Ok, + Fail: IActionResult (messages, notices) => + { + _logger.LogNotice(notices); + return NotFound(messages); + }); } + + [NonAction] + public override Task GetAll() => base.GetAll(); } \ No newline at end of file diff --git a/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeCertificateController.cs b/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeCertificateController.cs index a7f8778a..acf0a89f 100644 --- a/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeCertificateController.cs +++ b/EnvelopeGenerator.Web/Controllers/Test/TestEnvelopeCertificateController.cs @@ -2,13 +2,13 @@ using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Domain.Entities; -namespace EnvelopeGenerator.Web.Controllers.Test +namespace EnvelopeGenerator.Web.Controllers.Test; + +[Obsolete("Use MediatR")] +public class TestEnvelopeCertificateController : TestControllerBase { - public class TestEnvelopeCertificateController : TestControllerBase + public TestEnvelopeCertificateController(ILogger logger, IEnvelopeCertificateService service) : base(logger, service) { - public TestEnvelopeCertificateController(ILogger logger, IEnvelopeCertificateService service) : base(logger, service) - { - } } } \ No newline at end of file