< 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: 58
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.Http;
 5using Microsoft.AspNetCore.Mvc;
 6
 7namespace FAU.API.Controllers;
 8
 9/// <summary>
 10/// Catálogo de motivos de baja
 11/// </summary>
 12[ApiController]
 13[Route("api/motivos-baja")]
 14[Authorize]
 15[Produces("application/json")]
 16public class MotivoBajaController : ControllerBase
 17{
 18    private readonly IMotivoBajaService _motivoBajaService;
 19    private readonly ILogger<MotivoBajaController> _logger;
 20
 321    public MotivoBajaController(
 322        IMotivoBajaService motivoBajaService,
 323        ILogger<MotivoBajaController> logger)
 24    {
 325        _motivoBajaService = motivoBajaService;
 326        _logger = logger;
 327    }
 28
 29    /// <summary>
 30    /// Listar todos los motivos de baja vigentes
 31    /// GET /api/motivos-baja
 32    /// </summary>
 33    [HttpGet]
 34    [ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
 35    [ProducesResponseType(typeof(ApiResponse<string>), StatusCodes.Status500InternalServerError)]
 36    public async Task<IActionResult> GetMotivosBaja()
 37    {
 38        try
 39        {
 340            var motivos = await _motivoBajaService.GetAllVigentesAsync();
 41
 242            var response = motivos.Select(m => new
 243            {
 244                id = m.Id,
 245                codigo = m.Codigo,
 246                denominacion = m.Denominacion,
 247                vigente = m.Vigente
 248            });
 49
 250            return Ok(ApiResponse<object>.SuccessResult(response));
 51        }
 152        catch (Exception ex)
 53        {
 154            _logger.LogError(ex, "Error al obtener motivos de baja");
 155            return StatusCode(500, ApiResponse<string>.ErrorResult("Error interno del servidor"));
 56        }
 357    }
 58}