Refactor HomeController for MediatR and domain model
- Added new using directives for domain-driven design. - Marked several fields and methods as obsolete to transition to MediatR for request handling. - Updated action methods to use middleware for exception management. - Changed response type in EnvelopeSigned method for consistency with new domain model. - Overall improvements for maintainability and adherence to best practices.
This commit is contained in:
parent
dedfb924d8
commit
62a73e4967
@ -1,5 +1,4 @@
|
||||
using EnvelopeGenerator.CommonServices;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using EnvelopeGenerator.Web.Services;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -8,33 +7,40 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using DigitalData.Core.API;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using DigitalData.Core.DTO;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using static EnvelopeGenerator.CommonServices.Constants;
|
||||
using Ganss.Xss;
|
||||
using Newtonsoft.Json;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using DigitalData.Core.Client;
|
||||
using OtpNet;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers;
|
||||
|
||||
public class HomeController : ViewControllerBase
|
||||
{
|
||||
private readonly EnvelopeOldService envelopeOldService;
|
||||
[Obsolete("Use MediatR")]
|
||||
private readonly IEnvelopeReceiverService _envRcvService;
|
||||
[Obsolete("Use MediatR")]
|
||||
private readonly IEnvelopeHistoryService _historyService;
|
||||
private readonly IConfiguration _configuration;
|
||||
[Obsolete("Use MediatR")]
|
||||
private readonly IEnvelopeMailService _mailService;
|
||||
[Obsolete("Use MediatR")]
|
||||
private readonly IEnvelopeReceiverReadOnlyService _readOnlyService;
|
||||
private readonly IAuthenticator _authenticator;
|
||||
[Obsolete("Use MediatR")]
|
||||
private readonly IReceiverService _rcvService;
|
||||
private readonly IEnvelopeSmsHandler _envSmsHandler;
|
||||
|
||||
[Obsolete("Use MediatR")]
|
||||
public HomeController(EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IEnvelopeReceiverService envelopeReceiverService, IEnvelopeHistoryService historyService, IStringLocalizer<Resource> localizer, IConfiguration configuration, HtmlSanitizer sanitizer, Cultures cultures, IEnvelopeMailService envelopeMailService, IEnvelopeReceiverReadOnlyService readOnlyService, IAuthenticator authenticator, IReceiverService receiverService, IEnvelopeSmsHandler envelopeSmsService) : base(logger, sanitizer, cultures, localizer)
|
||||
{
|
||||
this.envelopeOldService = envelopeOldService;
|
||||
@ -69,6 +75,7 @@ public class HomeController : ViewControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}")]
|
||||
[Obsolete("Use MediatR")]
|
||||
public async Task<IActionResult> MainAsync([FromRoute] string envelopeReceiverId, [FromQuery] string? culture = null)
|
||||
{
|
||||
try
|
||||
@ -131,6 +138,7 @@ public class HomeController : ViewControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Locked")]
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId)
|
||||
{
|
||||
try
|
||||
@ -401,6 +409,7 @@ public class HomeController : ViewControllerBase
|
||||
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Success")]
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public async Task<IActionResult> EnvelopeSigned(string envelopeReceiverId)
|
||||
{
|
||||
try
|
||||
@ -412,7 +421,7 @@ public class HomeController : ViewControllerBase
|
||||
if(!isExisting)
|
||||
return this.ViewEnvelopeNotFound();
|
||||
|
||||
Common.EnvelopeReceiver response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
|
||||
EnvelopeReceiver response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
|
||||
if (!envelopeOldService.ReceiverAlreadySigned((Envelope)response.Envelope, (int)response.Receiver.Id))
|
||||
return base.Redirect($"/EnvelopeKey/{envelopeReceiverId}/Locked");
|
||||
|
||||
@ -436,6 +445,7 @@ public class HomeController : ViewControllerBase
|
||||
|
||||
[Authorize(Roles = ReceiverRole.FullyAuth)]
|
||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/Rejected")]
|
||||
[Obsolete("Use MediatR")]
|
||||
public async Task<IActionResult> EnvelopeRejected(string envelopeReceiverId)
|
||||
{
|
||||
try
|
||||
@ -467,6 +477,7 @@ public class HomeController : ViewControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("EnvelopeKey/{readOnlyKey}/ReadOnly")]
|
||||
[Obsolete("Use MediatR")]
|
||||
public async Task<IActionResult> EnvelopeReceiverReadOnly([FromRoute] string readOnlyKey)
|
||||
{
|
||||
try
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user