- Repository-Schnittstellen wurden in die Anwendungsschicht verschoben. - Erweiterungsmethoden für die Injektion von Repository-Abhängigkeiten wurden in die Infrastruktur verschoben.
52 lines
2.0 KiB
C#
52 lines
2.0 KiB
C#
using DigitalData.Core.DTO;
|
|
using EnvelopeGenerator.Application.Contracts.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class EnvelopeController : ControllerBase
|
|
{
|
|
private readonly ILogger<EnvelopeController> _logger;
|
|
private readonly IEnvelopeService _envelopeService;
|
|
|
|
public EnvelopeController(ILogger<EnvelopeController> logger, IEnvelopeService envelopeService)
|
|
{
|
|
_logger = logger;
|
|
_envelopeService = envelopeService;
|
|
}
|
|
|
|
[Authorize]
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetCurrentAsync(
|
|
[FromQuery] int? min_status = null,
|
|
[FromQuery] int? max_status = null,
|
|
[FromQuery] params int[] ignore_statuses)
|
|
{
|
|
try
|
|
{
|
|
if (User.GetId() is int intId)
|
|
return await _envelopeService.ReadByUserAsync(intId, min_status: min_status, max_status: max_status, ignore_statuses: ignore_statuses).ThenAsync(
|
|
Success: Ok,
|
|
Fail: IActionResult (msg, ntc) =>
|
|
{
|
|
_logger.LogNotice(ntc);
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
});
|
|
else
|
|
{
|
|
_logger.LogError("Despite successful authorization, the 'api/envelope' route encountered an issue: the user ID is not recognized as an integer. This may be due to the removal of the ID during the creation of the claims list.");
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "{Message}", ex.Message);
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
}
|
|
} |