refactor(HomeController): update EnvelopeLocked to use _mediator

This commit is contained in:
tekh 2025-09-08 12:58:29 +02:00
parent b78aff102a
commit beada59593

View File

@ -17,7 +17,6 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Newtonsoft.Json; using Newtonsoft.Json;
using OtpNet; using OtpNet;
using System.Security.Claims;
using EnvelopeGenerator.Domain.Constants; using EnvelopeGenerator.Domain.Constants;
namespace EnvelopeGenerator.Web.Controllers; namespace EnvelopeGenerator.Web.Controllers;
@ -110,20 +109,18 @@ public class HomeController : ViewControllerBase
[HttpGet("{envelopeReceiverId}/Locked")] [HttpGet("{envelopeReceiverId}/Locked")]
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")] [Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId) public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId, CancellationToken cancel)
{ {
try try
{ {
var envRcv = await _envRcvService.ReadByEnvelopeReceiverIdAsync(envelopeReceiverId: envelopeReceiverId); var er = await _mediator.ReadEnvelopeReceiverAsync(envelopeReceiverId, cancel);
if (envRcv.IsFailed)
if (er is null)
{ {
_logger.LogNotice(envRcv.Notices);
Response.StatusCode = StatusCodes.Status401Unauthorized; Response.StatusCode = StatusCodes.Status401Unauthorized;
return this.ViewEnvelopeNotFound(); return this.ViewEnvelopeNotFound();
} }
var er = envRcv.Data;
if (User.IsInRole(ReceiverRole.FullyAuth)) if (User.IsInRole(ReceiverRole.FullyAuth))
return await CreateShowEnvelopeView(envelopeReceiverId, er); return await CreateShowEnvelopeView(envelopeReceiverId, er);
else else