EnvelopeController aktualisiert, um das Ablehnen von Umschlägen mit optionalem Grund zu ermöglichen.

This commit is contained in:
Developer 02 2024-06-04 16:34:15 +02:00
parent 33f161a5fe
commit f16a8bcdb9
3 changed files with 5 additions and 5 deletions

View File

@ -19,6 +19,6 @@ namespace EnvelopeGenerator.Application.Contracts
Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null);
Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status);
Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null);
}
}

View File

@ -63,8 +63,8 @@ namespace EnvelopeGenerator.Application.Services
public async Task<IEnumerable<EnvelopeHistoryDto>> ReadRejectedAsync(int envelopeId, string? userReference = null) =>
await ReadAsync(envelopeId: envelopeId, userReference: userReference, status: (int)EnvelopeStatus.DocumentRejected);
public async Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status) =>
await CreateAsync(new (EnvelopeId: envelopeId, UserReference: userReference, Status: (int)status, ActionDate: DateTime.Now))
public async Task<DataResult<long>> RecordAsync(int envelopeId, string userReference, EnvelopeStatus status, string? comment = null) =>
await CreateAsync(new (EnvelopeId: envelopeId, UserReference: userReference, Status: (int)status, ActionDate: DateTime.Now, Comment: comment))
.ThenAsync(
Success: id => Result.Success(id),
Fail: (mssg, ntc) => Result.Fail<long>().Message(mssg).Notice(ntc)

View File

@ -115,7 +115,7 @@ namespace EnvelopeGenerator.Web.Controllers
[Authorize]
[HttpPost("reject")]
public async Task<IActionResult> Reject()
public async Task<IActionResult> Reject([FromBody] string? reason = null)
{
try
{
@ -137,7 +137,7 @@ namespace EnvelopeGenerator.Web.Controllers
return Unauthorized();
}
return await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected).ThenAsync(
return await _histService.RecordAsync(envRcvRes.Data.EnvelopeId, userReference: mail, EnvelopeStatus.DocumentRejected, comment: reason).ThenAsync(
Success: id => NoContent(),
Fail: IActionResult (mssg, ntc) =>
{