phronCare/phronCare.API/Controllers/Sales/CustomerController.cs
Leandro Hernan Rojas 143c3b45e7
Some checks failed
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Failing after 43s
Add Patch in CustomerController
2025-04-05 19:24:02 -03:00

48 lines
1.5 KiB
C#

using Core.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
namespace phronCare.API.Controllers.Sales
{
[Route("api/[controller]")]
[ApiController]
public class CustomerController : ControllerBase
{
private readonly ICustomerDom _customerService;
public CustomerController(ICustomerDom customerService)
{
_customerService = customerService ?? throw new ArgumentNullException(nameof(customerService));
}
[HttpGet("GetAll")]
public async Task<IActionResult> GetAll()
{
try
{
var result = await _customerService.GetAllAsync();
return Ok(result);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("search")]
public async Task<IActionResult> Search([FromQuery] string? name, [FromQuery] string? document, [FromQuery] string? email)
{
try
{
var result = await _customerService.SearchAsync(name, document,);
var result = await _customerService.SearchAsync(name, document,);
return Ok(result);
}
catch (Exception ex)
{
var methodName = MethodBase.GetCurrentMethod()?.Name ?? "UnknownMethod";
return StatusCode(500, $"{methodName} Message: {ex.Message}");
}
}
}
}