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.
This commit is contained in:
tekh 2025-06-27 13:11:40 +02:00
parent 3304b01d7b
commit 9d45082bfc
2 changed files with 32 additions and 31 deletions

View File

@ -1,33 +1,34 @@
using DigitalData.Core.DTO; using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.Contracts.Services; using EnvelopeGenerator.Application.Contracts.Services;
using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Domain.Entities;
using Microsoft.AspNetCore.Mvc; 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<IEmailTemplateService, EmailTemplateDto, EmailTemplate, int>
{ {
public class TestEmailTemplateController : TestControllerBase<IEmailTemplateService, EmailTemplateDto, EmailTemplate, int> public TestEmailTemplateController(ILogger<TestEmailTemplateController> logger, IEmailTemplateService service) : base(logger, service)
{ {
public TestEmailTemplateController(ILogger<TestEmailTemplateController> logger, IEmailTemplateService service) : base(logger, service)
{
}
[HttpGet]
public virtual async Task<IActionResult> 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<IActionResult> GetAll() => base.GetAll();
} }
[HttpGet]
[Obsolete("Use MediatR")]
public virtual async Task<IActionResult> 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<IActionResult> GetAll() => base.GetAll();
} }

View File

@ -2,13 +2,13 @@
using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Web.Controllers.Test namespace EnvelopeGenerator.Web.Controllers.Test;
{
public class TestEnvelopeCertificateController : TestControllerBase<IEnvelopeCertificateService, EnvelopeCertificateDto, EnvelopeCertificate, int> [Obsolete("Use MediatR")]
{ public class TestEnvelopeCertificateController : TestControllerBase<IEnvelopeCertificateService, EnvelopeCertificateDto, EnvelopeCertificate, int>
public TestEnvelopeCertificateController(ILogger<TestEnvelopeCertificateController> logger, IEnvelopeCertificateService service) : base(logger, service) {
{ public TestEnvelopeCertificateController(ILogger<TestEnvelopeCertificateController> logger, IEnvelopeCertificateService service) : base(logger, service)
{
}
} }
} }