refactor(ReadHistoryQuery): update to not throw exception.
- update controller to throw NotFound if the list is empty
This commit is contained in:
@@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Application.Histories.Queries;
|
||||
using DigitalData.Core.Client;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
||||
|
||||
@@ -107,8 +109,7 @@ public class HistoryController : ControllerBase
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GetAllAsync([FromQuery] ReadHistoryQuery historyQuery)
|
||||
{
|
||||
var history = await _mediator.Send(historyQuery);
|
||||
|
||||
var history = await _mediator.Send(historyQuery).ThrowIfEmpty(Exceptions.NotFound);
|
||||
return Ok((historyQuery.OnlyLast ?? false) ? history.MaxBy(h => h.AddedWhen) : history);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user