phronCare/phronCare.API/Controllers/Sales/TaxConditionController.cs

41 lines
1.2 KiB
C#
Raw Normal View History

2025-04-10 16:14:53 -03:00
using Core.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace phronCare.API.Controllers.Sales
{
[Route("api/[controller]")]
[ApiController]
public class TaxConditionController : ControllerBase
{
private readonly ITaxConditionDom _taxConditionService ;
public TaxConditionController(ITaxConditionDom taxConditionService)
{
_taxConditionService = taxConditionService ?? throw new ArgumentNullException(nameof(taxConditionService));
}
[HttpGet("GetAll")]
public async Task<IActionResult> GetAll()
{
try
{
var result = await _taxConditionService.GetAllAsync();
return Ok(result);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("GetByName/{name}")]
public async Task<IActionResult> GetByName(string name)
{
var result = await _taxConditionService.GetByNameAsync(name);
if (result == null)
return NotFound($"No se encontró un tipo de cuenta con el nombre '{name}'.");
return Ok(result);
}
}
}