feat(ReadOnlyController): Try-Catch zur 'CreateAsync'-Methode hinzugefügt.

- Unnötige Testmethoden wurden aus dem Controller entfernt.
This commit is contained in:
Developer 02
2024-10-14 09:38:16 +02:00
parent c4f0ce7d4b
commit c9410a1e2e

View File

@@ -28,17 +28,11 @@ namespace EnvelopeGenerator.Web.Controllers
_histService = histService; _histService = histService;
} }
[HttpGet]
[Authorize]
public async Task<IActionResult> GetAllAsync()
{
var res = await _erroService.ReadAllAsync();
return Ok(res);
}
[HttpPost] [HttpPost]
[Authorize] [Authorize]
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto) public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
{
try
{ {
//set AddedWho //set AddedWho
var authReceiverMail = this.GetAuthReceiverMail(); var authReceiverMail = this.GetAuthReceiverMail();
@@ -82,7 +76,7 @@ namespace EnvelopeGenerator.Web.Controllers
{ {
//TODO: implement multi-threading to history process (Task) //TODO: implement multi-threading to history process (Task)
//TODO: remove casting after change the id type //TODO: remove casting after change the id type
var hist_res = await _histService.RecordAsync((int) createDto.EnvelopeId, createDto.AddedWho, Common.Constants.EnvelopeStatus.EnvelopeShared); var hist_res = await _histService.RecordAsync((int)createDto.EnvelopeId, createDto.AddedWho, Common.Constants.EnvelopeStatus.EnvelopeShared);
if (hist_res.IsFailed) if (hist_res.IsFailed)
{ {
_logger.LogError("Although the envelope was sent as read-only, the EnvelopeShared hisotry could not be saved. Create DTO:\n{createDto}", JsonConvert.SerializeObject(createDto)); _logger.LogError("Although the envelope was sent as read-only, the EnvelopeShared hisotry could not be saved. Create DTO:\n{createDto}", JsonConvert.SerializeObject(createDto));
@@ -98,9 +92,11 @@ namespace EnvelopeGenerator.Web.Controllers
return StatusCode(StatusCodes.Status500InternalServerError); return StatusCode(StatusCodes.Status500InternalServerError);
}); });
} }
catch(Exception ex)
[HttpGet("key/{readOnlyId}")] {
public IActionResult CreateLink(long readOnlyId) => Ok( _logger.LogError(ex, "{Message}", ex.Message);
Request.Headers["Origin"].ToString() + "/EnvelopeKey/" + readOnlyId.EncodeEnvelopeReceiverId()); return StatusCode(StatusCodes.Status500InternalServerError);
}
}
} }
} }