Files
moadiran/TaxPayerFull/FixedValues.cs

157 lines
4.8 KiB
C#
Raw Normal View History

2024-07-27 23:20:15 +03:30
using BlazorBootstrap;
using Front.Services;
2024-05-17 23:05:46 +03:30
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-07-03 16:52:31 +03:30
public string Domin { get; set; } = "http://195.88.208.142";
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-07-27 23:20:15 +03:30
2024-07-28 15:34:46 +03:30
private List<PromotionDto> Promotions { 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-07-30 12:14:36 +03:30
public async Task LoadDashBoard(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>();
}
}
}
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)
{
2024-07-27 23:20:15 +03:30
await _hc.Post<UlrDto>("Base/Ulr", new UlrDto { Type = Type });
}
public async Task<List<PromotionDto>> LoadPromotion()
{
2024-07-28 15:34:46 +03:30
if (Promotions == null)
{
List<PricingDto> Pricing = new List<PricingDto>();
var rsp = await _hc.Get($"Orders/GetAllPromotion");
2024-07-27 23:20:15 +03:30
if (rsp.IsSuccessStatusCode)
2024-07-28 15:34:46 +03:30
{
Promotions = await rsp.Content.ReadFromJsonAsync<List<PromotionDto>>() ?? new List<PromotionDto>();
rsp = await _hc.Get($"Orders/GetAllPricing");
if (rsp.IsSuccessStatusCode)
Pricing = await rsp.Content.ReadFromJsonAsync<List<PricingDto>>() ?? new List<PricingDto>();
if (Pricing.Count>0)
{
Promotions.Add(new PromotionDto()
{
ID = -1,
2024-07-28 22:58:39 +03:30
Name = "شخصی سازی",
2024-07-28 15:34:46 +03:30
promotionDetails = Pricing.Select(s => new PromotionDetailDto
{
ID = 0,
APrice = s.Price,
CreditAmount = 0,
PermissionID = s.PermissionID,
PermissionTitle = s.PermissionTitle
}).ToList()
});
}
}
2024-07-27 23:20:15 +03:30
}
2024-07-28 15:34:46 +03:30
return Promotions ?? new List<PromotionDto>();
2024-07-27 23:20:15 +03:30
2024-06-18 13:59:32 +03:30
}
2024-04-18 18:26:12 +03:30
}
2024-06-18 13:59:32 +03:30
}