Files
moadiran/TaxPayerFull/FixedValues.cs

116 lines
3.2 KiB
C#
Raw Normal View History

2024-05-17 23:05:46 +03:30
using Front.Services;
using Shared.DTOs;
using System.Net.Http.Json;
2024-06-18 13:59:32 +03:30
using System.Security.Cryptography;
2024-04-18 18:26:12 +03:30
namespace Front
{
2024-05-17 23:05:46 +03:30
public class Fixedvalues
2024-04-18 18:26:12 +03:30
{
2024-05-17 23:05:46 +03:30
public readonly HttpClientController _hc;
2024-06-18 13:59:32 +03:30
private List<ForCustomerSearch>? Cus = null;
2024-05-17 23:05:46 +03:30
private List<IdName<int>>? Patterns = null;
2024-06-18 13:59:32 +03:30
private List<IdName<int>>? Units = null;
2024-05-23 19:59:19 +03:30
private List<CODIdName<int>>? Cods = null;
2024-06-14 22:37:22 +03:30
private CompanyDTO? InfoCompany = null;
2024-06-18 13:59:32 +03:30
public InvoiceDTO? invoice { get; set; } = null;
2024-06-25 20:54:16 +03:30
public DashBoardDTO? dashBoard { get; set; } = null;
2024-05-17 23:05:46 +03:30
public Fixedvalues(HttpClientController hc)
{
_hc = hc;
}
public async Task<List<ForCustomerSearch>?> GetCustomers()
2024-06-18 13:59:32 +03:30
{
if (Cus == null)
2024-05-17 23:05:46 +03:30
{
var request = await _hc.Get($"Customer/GetAllForidName");
if (request.IsSuccessStatusCode)
{
2024-06-18 13:59:32 +03:30
Cus = await request.Content.ReadFromJsonAsync<List<ForCustomerSearch>>();
2024-05-17 23:05:46 +03:30
}
}
2024-06-18 13:59:32 +03:30
return Cus;
2024-05-17 23:05:46 +03:30
2024-05-23 19:59:19 +03:30
}
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;
2024-05-17 23:05:46 +03:30
}
public async Task<List<IdName<int>>?> GetPatterns()
{
2024-06-18 13:59:32 +03:30
if (Patterns == null)
2024-05-17 23:05:46 +03:30
{
var request = await _hc.Get($"Invoice/GetPatterns");
if (request.IsSuccessStatusCode)
{
2024-06-18 13:59:32 +03:30
Patterns = await request.Content.ReadFromJsonAsync<List<IdName<int>>>();
2024-05-17 23:05:46 +03:30
}
}
return Patterns;
}
2024-06-14 22:37:22 +03:30
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;
}
2024-06-25 20:54:16 +03:30
public async Task<DashBoardDTO?> GetDashBoard(bool run=false)
2024-06-16 16:15:56 +03:30
{
2024-06-25 20:54:16 +03:30
if (dashBoard == null || run)
2024-06-16 16:15:56 +03:30
{
var rsp = await _hc.Get("User/GetDashBoard");
if (rsp.IsSuccessStatusCode)
{
dashBoard = await rsp.Content.ReadFromJsonAsync<DashBoardDTO>();
}
}
return dashBoard;
}
2024-06-18 13:59:32 +03:30
public async Task<List<IdName<int>>> GetUnits()
{
if (Units == null)
{
var rsp = await _hc.Get("COD/GetUnits");
if (rsp.IsSuccessStatusCode)
{
Units = await rsp.Content.ReadFromJsonAsync<List<IdName<int>>>();
}
}
return Units;
2024-06-30 19:57:32 +03:30
}
public async Task SetUlr(string Type)
{
await _hc.Post<UlrDto>("Base/Ulr",new UlrDto { Type=Type});
2024-06-18 13:59:32 +03:30
}
2024-04-18 18:26:12 +03:30
}
2024-06-18 13:59:32 +03:30
}