You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
204 lines
6.7 KiB
204 lines
6.7 KiB
using Biskilog_Accounting.Client.Pages.Transactions.Elements;
|
|
using Biskilog_Accounting.Shared.CustomModels;
|
|
using Biskilog_Accounting.Shared.Interfaces;
|
|
using Biskilog_Accounting.Shared.POSModels;
|
|
using Radzen;
|
|
using System.Text.Json;
|
|
|
|
namespace Biskilog_Accounting.Client.Repos
|
|
{
|
|
public class MainInterfaceService : IMainInterface, ICompanyInfo, IUser, ICustomer
|
|
{
|
|
private readonly HttpClient m_http;
|
|
private readonly DialogService m_dialogService;
|
|
private DateTime m_currentTradeDate;
|
|
private DateTime m_previousTradeDate;
|
|
private IEnumerable<Tblbranch> m_branches { get; set; } = new List<Tblbranch>();
|
|
private IEnumerable<Tbluser> m_users { get; set; } = new List<Tbluser>();
|
|
private IEnumerable<CustomerAccounts> m_customers { get; set; } = new List<CustomerAccounts>();
|
|
private Tblcompanydetail m_info;
|
|
|
|
public MainInterfaceService(DialogService a_dialogService, HttpClient http)
|
|
{
|
|
m_dialogService = a_dialogService;
|
|
m_currentTradeDate = new DateTime(2023, 05, 01);
|
|
m_previousTradeDate = new DateTime(2023, 04, 01);
|
|
m_http = http;
|
|
|
|
}
|
|
|
|
async Task OpenReceiptDialog(string a_receiptId)
|
|
{
|
|
await m_dialogService.OpenSideAsync<ReceiptDialog>("Receipt",
|
|
new Dictionary<string, object>() { { "ReceiptId", a_receiptId } },
|
|
options: new SideDialogOptions
|
|
{
|
|
CloseDialogOnOverlayClick = true,
|
|
Position = DialogPosition.Right,
|
|
ShowMask = true,
|
|
ShowTitle = false,
|
|
});
|
|
}
|
|
public void ShowReceipt(string a_receiptId)
|
|
{
|
|
OpenReceiptDialog(a_receiptId);
|
|
}
|
|
|
|
public DateOnly CurrentTradeDate()
|
|
{
|
|
return DateOnly.FromDateTime(m_currentTradeDate);
|
|
}
|
|
|
|
public DateOnly PreviousTradeDate()
|
|
{
|
|
return DateOnly.FromDateTime(m_previousTradeDate);
|
|
}
|
|
|
|
public IEnumerable<Tblbranch> FetchBranches()
|
|
{
|
|
return m_branches;
|
|
}
|
|
|
|
public async Task<Tblcompanydetail> GetCompanyInfoAsync()
|
|
{
|
|
var response = await m_http.GetAsync($"api/companyinfo/info");
|
|
if (response.IsSuccessStatusCode)
|
|
{
|
|
var jsonContent = await response.Content.ReadAsStringAsync();
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
|
var recent = JsonSerializer.Deserialize<Tblcompanydetail>(jsonContent, options);
|
|
m_info = recent;
|
|
return recent;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public async Task<IEnumerable<Tblbranch>> GetBranches()
|
|
{
|
|
var response = await m_http.GetAsync($"api/companyinfo/branches");
|
|
if (response.IsSuccessStatusCode)
|
|
{
|
|
var jsonContent = await response.Content.ReadAsStringAsync();
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
|
var recent = JsonSerializer.Deserialize<IEnumerable<Tblbranch>>(jsonContent, options);
|
|
m_branches = recent;
|
|
return recent;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public string GetCompanyName()
|
|
{
|
|
return m_info.CompanyName;
|
|
}
|
|
|
|
public string GetBranchName(string a_branchId)
|
|
{
|
|
return m_branches.First(b => b.BranchId == a_branchId).BranchName;
|
|
}
|
|
|
|
public IEnumerable<Tbluser> FetchUsers()
|
|
{
|
|
return m_users;
|
|
}
|
|
|
|
public async Task<IEnumerable<Tbluser>> GetUsers()
|
|
{
|
|
var response = await m_http.GetAsync($"api/users/accounts");
|
|
if (response.IsSuccessStatusCode)
|
|
{
|
|
var jsonContent = await response.Content.ReadAsStringAsync();
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
|
var recent = JsonSerializer.Deserialize<IEnumerable<Tbluser>>(jsonContent, options);
|
|
m_users = recent;
|
|
return recent;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public IEnumerable<CustomerAccounts> FetchCustomers()
|
|
{
|
|
return m_customers;
|
|
}
|
|
|
|
public async Task<IEnumerable<CustomerAccounts>> GetCustomers()
|
|
{
|
|
var response = await m_http.GetAsync($"api/customer/accounts");
|
|
if (response.IsSuccessStatusCode)
|
|
{
|
|
var jsonContent = await response.Content.ReadAsStringAsync();
|
|
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
|
var recent = JsonSerializer.Deserialize<IEnumerable<CustomerAccounts>>(jsonContent, options);
|
|
m_customers = recent;
|
|
return recent;
|
|
}
|
|
return null;
|
|
}
|
|
#region Unimplemented
|
|
public Task SyncBranches(List<Tblbranch> a_branches)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncCompanyDetails(List<Tblcompanydetail> a_details)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncDriverDetails(List<Tbldriver> a_details)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncSustemRoles(List<Systemuserrole> a_roles)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncTrucks(List<Tbltruck> a_trucks)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncTruckAssignments(List<Tbltruckassignment> a_assignments)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncTruckMappings(List<TbltruckDrivermapping> a_mapping)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncTruckInventory(List<Tbltruckinventory> a_inventories)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public DateTime GetLastSyncDate(string a_tablename)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void SetLastSyncDate(string a_tableName, DateTime a_timestamp)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncUserAsync(List<Tbluser> a_users)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncCustomers(List<Tblcustomer> a_details)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task SyncSystemRoles(List<Systemuserrole> a_roles)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|