78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using Front.Services;
|
|
using Shared.DTOs;
|
|
using System.Net.Http.Json;
|
|
|
|
namespace Front
|
|
{
|
|
public class Fixedvalues
|
|
{
|
|
public readonly HttpClientController _hc;
|
|
private List<ForCustomerSearch>? Cus=null;
|
|
private List<IdName<int>>? Patterns = null;
|
|
private List<CODIdName<int>>? Cods = null;
|
|
private CompanyDTO? InfoCompany = null;
|
|
public InvoiceDTO? invoice { get; set; }=null;
|
|
public Fixedvalues(HttpClientController hc)
|
|
{
|
|
_hc = hc;
|
|
}
|
|
public async Task<List<ForCustomerSearch>?> GetCustomers()
|
|
{
|
|
if (Cus == null)
|
|
{
|
|
var request = await _hc.Get($"Customer/GetAllForidName");
|
|
if (request.IsSuccessStatusCode)
|
|
{
|
|
Cus= await request.Content.ReadFromJsonAsync<List<ForCustomerSearch>>();
|
|
}
|
|
}
|
|
|
|
return Cus;
|
|
|
|
|
|
}
|
|
public async Task<List<CODIdName<int>>?> GetCODs()
|
|
{
|
|
if (Cods == null)
|
|
{
|
|
var request = await _hc.Get($"COD/GetAllForidName");
|
|
if (request.IsSuccessStatusCode)
|
|
{
|
|
Cods = await request.Content.ReadFromJsonAsync<List<CODIdName<int>>>();
|
|
}
|
|
}
|
|
|
|
return Cods;
|
|
|
|
|
|
}
|
|
public async Task<List<IdName<int>>?> GetPatterns()
|
|
{
|
|
if (Patterns==null)
|
|
{
|
|
var request = await _hc.Get($"Invoice/GetPatterns");
|
|
if (request.IsSuccessStatusCode)
|
|
{
|
|
Patterns =await request.Content.ReadFromJsonAsync<List<IdName<int>>>();
|
|
}
|
|
}
|
|
|
|
|
|
return Patterns;
|
|
}
|
|
public async Task<CompanyDTO?> GetInfoCompany()
|
|
{
|
|
|
|
if (InfoCompany == null)
|
|
{
|
|
var rspCompany = await _hc.Get($"Company/GetCompany");
|
|
if (rspCompany.IsSuccessStatusCode)
|
|
InfoCompany = await rspCompany.Content.ReadFromJsonAsync<CompanyDTO>();
|
|
}
|
|
|
|
|
|
return InfoCompany;
|
|
}
|
|
}
|
|
}
|