Enhance DTOs and controller with documentation and checks
- Added XML documentation comments to properties in `EnvelopeHistoryDto.cs`. - Changed `EnvelopeId` to non-nullable in `ReadHistoryQuery.cs` and added `Status` parameter for filtering. - Removed unused `using` directives in `HistoryController.cs` and updated `GetAllAsync` to filter histories by `Status`, returning `NotFound` if no results are found.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -7,7 +6,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using static EnvelopeGenerator.Common.Constants;
|
||||
|
||||
|
||||
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
||||
|
||||
/// <summary>
|
||||
@@ -109,8 +107,6 @@ public class HistoryController : ControllerBase
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GetAllAsync([FromQuery] ReadHistoryQuery history)
|
||||
{
|
||||
|
||||
|
||||
bool withReceiver = false;
|
||||
bool withSender = false;
|
||||
|
||||
@@ -130,6 +126,12 @@ public class HistoryController : ControllerBase
|
||||
withSender: withSender,
|
||||
withReceiver: withReceiver);
|
||||
|
||||
return Ok(histories);
|
||||
if(history.Status is not null)
|
||||
histories = histories.Where(h => h.Status == (int)history.Status);
|
||||
|
||||
if (!histories.Any())
|
||||
return NotFound();
|
||||
|
||||
return Ok((history.OnlyLast ?? false) ? histories.MaxBy(h => h.AddedWhen) : histories);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user