Leandro Hernan Rojas 31edbf577f
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 3m8s
Add Patch 3 in API
2025-04-03 18:27:56 -03:00

75 lines
2.4 KiB
C#

using Core.Interfaces;
using Domain.Entities;
using Microsoft.AspNetCore.Mvc;
namespace phronCare.API.Controllers.Tickets
{
[Route("api/[controller]")]
[ApiController]
public class TicketController : ControllerBase
{
private readonly ITicketDom _ticketService;
// Constructor que acepta ITicketDom como parámetro
public TicketController(ITicketDom ticketService)
{
_ticketService = ticketService ?? throw new ArgumentNullException(nameof(ticketService));
}
[HttpPost("InsertTicket")]
public async Task<IActionResult> InsertTicket([FromBody] ETicket ticket)
{
try
{
await _ticketService.InsertTicketAsync(ticket); // Llamada asincrónica
return Ok();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("GetSummary")]
public async Task<IActionResult> GetSummary()
{
try
{
var summary = await _ticketService.GetSummaryAsync(); // Llamada asincrónica
return Ok(summary);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost("GetDashboardDetail")]
public async Task<IActionResult> GetDashboardDetail([FromBody] GenericParameters<string, string, object, object, object> parameters)
{
try
{
var dashboardDetail = await _ticketService.GetTicketDashboardAsync(parameters.Param1, parameters.Param2); // Llamada asincrónica
return Ok(dashboardDetail);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost("ExportDashboardDetail")]
public async Task<FileResult> ExportDashboardDetail([FromBody] GenericParameters<string, string, object, object, object> parameters)
{
try
{
var file = await _ticketService.ExcelTicketDashboardAsync(parameters.Param1, parameters.Param2); // Llamada asincrónica
return File(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
catch (Exception ex)
{
throw new InvalidDataException(ex.Message);
}
}
}
}