< Summary

Information
Class: FAU.API.Controllers.MotivoBajaController
Assembly: FAU.API
File(s): /home/runner/work/Sistema.Liquidacion.BE/Sistema.Liquidacion.BE/FAU.API/Controllers/MotivoBajaController.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 54
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetMotivosBaja()100%11100%

File(s)

/home/runner/work/Sistema.Liquidacion.BE/Sistema.Liquidacion.BE/FAU.API/Controllers/MotivoBajaController.cs

#LineLine coverage
 1using FAU.Logica.DTOs;
 2using FAU.Logica.Services;
 3using Microsoft.AspNetCore.Authorization;
 4using Microsoft.AspNetCore.Mvc;
 5
 6namespace FAU.API.Controllers;
 7
 8/// <summary>
 9/// Catálogo público de motivos de baja
 10/// </summary>
 11[ApiController]
 12[Route("api/motivos-baja")]
 13[AllowAnonymous]
 14public class MotivoBajaController : ControllerBase
 15{
 16    private readonly IMotivoBajaService _motivoBajaService;
 17    private readonly ILogger<MotivoBajaController> _logger;
 18
 319    public MotivoBajaController(
 320        IMotivoBajaService motivoBajaService,
 321        ILogger<MotivoBajaController> logger)
 22    {
 323        _motivoBajaService = motivoBajaService;
 324        _logger = logger;
 325    }
 26
 27    /// <summary>
 28    /// Listar todos los motivos de baja vigentes
 29    /// GET /api/motivos-baja
 30    /// </summary>
 31    [HttpGet]
 32    public async Task<IActionResult> GetMotivosBaja()
 33    {
 34        try
 35        {
 336            var motivos = await _motivoBajaService.GetAllVigentesAsync();
 37
 238            var response = motivos.Select(m => new
 239            {
 240                id = m.Id,
 241                codigo = m.Codigo,
 242                denominacion = m.Denominacion,
 243                vigente = m.Vigente
 244            });
 45
 246            return Ok(ApiResponse<object>.SuccessResult(response));
 47        }
 148        catch (Exception ex)
 49        {
 150            _logger.LogError(ex, "Error al obtener motivos de baja");
 151            return StatusCode(500, ApiResponse<string>.ErrorResult("Error interno del servidor"));
 52        }
 353    }
 54}