feat(EnvelopeReceiverReadOnly): Created endpoint for ShowEnvelope view
This commit is contained in:
@@ -15,8 +15,6 @@ using System.Text.Encodings.Web;
|
||||
using EnvelopeGenerator.Web.Models;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using System.Text.RegularExpressions;
|
||||
using static EnvelopeGenerator.Common.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers
|
||||
@@ -307,15 +305,36 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("EnvelopeKey/{envelopeReceiverId}/ReadOnly")]
|
||||
public async Task<IActionResult> EnvelopeReceiverReadOnly(string readOnlyId)
|
||||
[HttpGet("EnvelopeKey/{readOnlyId}/ReadOnly")]
|
||||
public async Task<IActionResult> EnvelopeReceiverReadOnly(string readOnlyKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Ok();
|
||||
readOnlyKey = _urlEncoder.Encode(readOnlyKey);
|
||||
|
||||
// check if the readOnlyId is valid
|
||||
if (!readOnlyKey.TryDecode(out var decodedKeys) || decodedKeys.GetEncodeType() != EncodeType.EnvelopeReceiverReadOnly)
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
return this.ViewDocumentNotFound();
|
||||
}
|
||||
|
||||
var readOnlyId = decodedKeys.ParseReadOnlyId();
|
||||
return await _readOnlyService.ReadByIdAsync(readOnlyId).ThenAsync(
|
||||
Success: erro =>
|
||||
{
|
||||
ViewData["model"] = erro;
|
||||
return View("ShowEnvelope");
|
||||
},
|
||||
Fail: IActionResult (msg, ntc) =>
|
||||
{
|
||||
_logger.LogNotice(ntc);
|
||||
return this.ViewInnerServiceError();
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "An unexpected error occurred while displaying a read-only envelope. Read-only key is {readOnlyKey}. {message}", readOnlyKey, ex.Message);
|
||||
return this.ViewInnerServiceError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user