This commit introduces XML documentation comments to the GetReferenceTypes method in the HistoryController class. The comments clarify the method's purpose, indicating that it retrieves available reference types and returns them as key-value pairs, along with a summary and return type information.
67 lines
2.7 KiB
C#
67 lines
2.7 KiB
C#
using DigitalData.Core.DTO;
|
|
using EnvelopeGenerator.Application.Contracts.Services;
|
|
using EnvelopeGenerator.Application.EnvelopeHistories;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace EnvelopeGenerator.GeneratorAPI.Controllers;
|
|
|
|
/// <summary>
|
|
/// Dieser Controller stellt Endpunkte für die Verwaltung von Umschlägen bereit.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Die API ermöglicht das Abrufen und Verwalten von Umschlägen basierend auf Benutzerinformationen und Statusfiltern.
|
|
/// </remarks>
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class EnvelopeController : ControllerBase
|
|
{
|
|
private readonly ILogger<EnvelopeController> _logger;
|
|
private readonly IEnvelopeService _envelopeService;
|
|
|
|
/// <summary>
|
|
/// Erstellt eine neue Instanz des EnvelopeControllers.
|
|
/// </summary>
|
|
/// <param name="logger">Der Logger, der für das Protokollieren von Informationen verwendet wird.</param>
|
|
/// <param name="envelopeService">Der Dienst, der für die Verarbeitung von Umschlägen zuständig ist.</param>
|
|
public EnvelopeController(ILogger<EnvelopeController> logger, IEnvelopeService envelopeService)
|
|
{
|
|
_logger = logger;
|
|
_envelopeService = envelopeService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ruft eine Liste von Umschlägen basierend auf dem Benutzer und den angegebenen Statusfiltern ab.
|
|
/// </summary>
|
|
/// <param name="status">Die Statusfilter, die für die Abfrage verwendet werden sollen.</param>
|
|
/// <returns>Eine IActionResult-Instanz, die die abgerufenen Umschläge oder einen Fehlerstatus enthält.</returns>
|
|
[Authorize]
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetAsync(
|
|
[FromQuery] StatusQuery status)
|
|
{
|
|
try
|
|
{
|
|
if (User.GetId() is int intId)
|
|
return await _envelopeService.ReadByUserAsync(intId, min_status: status.Min, max_status: status.Max, ignore_statuses: status.Ignore ?? Array.Empty<int>()).ThenAsync(
|
|
Success: Ok,
|
|
Fail: IActionResult (msg, ntc) =>
|
|
{
|
|
_logger.LogNotice(ntc);
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
});
|
|
else
|
|
{
|
|
_logger.LogError("Trotz erfolgreicher Autorisierung wurde die Benutzer-ID nicht als Ganzzahl erkannt. Dies könnte auf eine fehlerhafte Erstellung der Anspruchsliste zurückzuführen sein.");
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "{Message}", ex.Message);
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
}
|