42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using Domain.Entities;
|
|
using System.Net.Http.Json;
|
|
|
|
|
|
namespace phronCare.UIBlazor.Services.Tickets
|
|
{
|
|
public class TicketsService
|
|
{
|
|
private readonly HttpClient _httpClient;
|
|
public List<ETicket_Dashboard>? dashboard;
|
|
public TicketsService(HttpClient httpClient)
|
|
{
|
|
_httpClient = httpClient;
|
|
}
|
|
|
|
public async Task<IEnumerable<ETickets_GetSummary>> GetSummary()
|
|
{
|
|
var response = await _httpClient.GetFromJsonAsync<IEnumerable<ETickets_GetSummary>>("/api/Ticket/GetSummary");
|
|
if (response is null)
|
|
{
|
|
response = Enumerable.Empty<ETickets_GetSummary>();
|
|
}
|
|
return response;
|
|
}
|
|
public async Task<IEnumerable<ETicket_Dashboard>> GetDashboardDetail(string estado, string orden)
|
|
{
|
|
try
|
|
{
|
|
var response = await _httpClient.PostAsJsonAsync("/api/Ticket/GetDashboardDetail", new { Param1 = estado, Param2 = orden });
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
var content = await response.Content.ReadFromJsonAsync<IEnumerable<ETicket_Dashboard>>();
|
|
return content ?? Enumerable.Empty<ETicket_Dashboard>();
|
|
}
|
|
catch (HttpRequestException ex)
|
|
{
|
|
throw new Exception("Error al obtener el dashboard: " + ex.Message, ex);
|
|
}
|
|
}
|
|
}
|
|
}
|