From 90bdb526ab058e87a0ce4e6fb15b1c42dcc45ac3 Mon Sep 17 00:00:00 2001 From: barhen Date: Sun, 17 Dec 2023 17:29:24 -0500 Subject: [PATCH] Removed all sync controllers from Biskilog account backend --- Server/CloudHubs/SalesHub.cs | 18 --- Server/Services/SalesService.cs | 19 +-- .../SyncCompanyInfoController.cs | 151 ------------------ .../SyncControllers/SyncProductsController.cs | 145 ----------------- Server/SyncControllers/SyncSalesController.cs | 145 ----------------- Shared/Interfaces/ICompanyInfo.cs | 10 -- Shared/Interfaces/ICustomer.cs | 1 - Shared/Interfaces/IProducts.cs | 12 -- Shared/Interfaces/ISalesHub.cs | 10 -- Shared/Interfaces/ISalesInterface.cs | 12 -- Shared/Interfaces/IUser.cs | 1 - 11 files changed, 8 insertions(+), 516 deletions(-) delete mode 100644 Server/CloudHubs/SalesHub.cs delete mode 100644 Server/SyncControllers/SyncCompanyInfoController.cs delete mode 100644 Server/SyncControllers/SyncProductsController.cs delete mode 100644 Server/SyncControllers/SyncSalesController.cs delete mode 100644 Shared/Interfaces/ISalesHub.cs diff --git a/Server/CloudHubs/SalesHub.cs b/Server/CloudHubs/SalesHub.cs deleted file mode 100644 index 05c6934..0000000 --- a/Server/CloudHubs/SalesHub.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Biskilog_Accounting.Shared.CustomModels; -using Biskilog_Accounting.Shared.Interfaces; -using Microsoft.AspNetCore.SignalR; - -namespace Biskilog_Accounting.Server.CloudHubs -{ - public class SalesHub : Hub - { - public async Task JoinCompanyGroup(string a_companyId) - { - await Groups.AddToGroupAsync(Context.ConnectionId, a_companyId); - } - public async Task AddTransaction(string a_companyId, SaleItem a_sale) - { - await Clients.OthersInGroup(a_companyId).TransactionMade(a_sale); - } - } -} diff --git a/Server/Services/SalesService.cs b/Server/Services/SalesService.cs index 3693a8e..7433f86 100644 --- a/Server/Services/SalesService.cs +++ b/Server/Services/SalesService.cs @@ -1,5 +1,4 @@ -using Biskilog_Accounting.Server.CloudHubs; -using Biskilog_Accounting.Server.POSModels; +using Biskilog_Accounting.Server.POSModels; using Biskilog_Accounting.Shared.CustomModels; using Biskilog_Accounting.Shared.Enums; using Biskilog_Accounting.Shared.Interfaces; @@ -17,19 +16,17 @@ namespace Biskilog_Accounting.Server.Services private readonly BiskAcdbContext m_context; private readonly ITokenService m_tokenService; private readonly HttpContext m_httpContext; - private readonly IHubContext m_salesHub; public event EventHandler TransactionsChanged; public event EventHandler FetchComplete; public event EventHandler FetchStart; public SalesService(BiskAcdbContext a_context, ITokenService a_tokenService, - IHttpContextAccessor a_httpContextAccessor, IHubContext a_salesHub) + IHttpContextAccessor a_httpContextAccessor) { m_context = a_context; m_tokenService = a_tokenService; m_httpContext = a_httpContextAccessor?.HttpContext; - m_salesHub = a_salesHub; } public Task FetchRecentTransaction(int a_limit) @@ -154,17 +151,17 @@ namespace Biskilog_Accounting.Server.Services Id = reader.GetString(0), Quantity = reader.GetInt32(1), Date = reader.GetDateTime(2), - Price = reader.GetDecimal(3), + Price = reader.IsDBNull(3) ? 0 : reader.GetDecimal(3), Cashier = reader.GetString(4), Status = reader.GetString(5), - Total = (decimal)reader.GetDouble(6), + Total = reader.IsDBNull(6) ? 0 : reader.GetDecimal(6), Unit = reader.GetString(7), - Costprice = reader.GetDecimal(8), + Costprice = reader.IsDBNull(8) ? 0 : reader.GetDecimal(8), BranchId = reader.GetString(9), CountId = reader.GetString(10), - Tendered = reader.GetDecimal(11), - Balance = reader.GetDecimal(12), - ValueAddTax = reader.GetDecimal(13) + Tendered = reader.IsDBNull(11) ? 0 : reader.GetDecimal(11), + Balance = reader.IsDBNull(12) ? 0 : reader.GetDecimal(12), + ValueAddTax = reader.IsDBNull(13) ? 0 : reader.GetDecimal(13) }); } } diff --git a/Server/SyncControllers/SyncCompanyInfoController.cs b/Server/SyncControllers/SyncCompanyInfoController.cs deleted file mode 100644 index 1abcc12..0000000 --- a/Server/SyncControllers/SyncCompanyInfoController.cs +++ /dev/null @@ -1,151 +0,0 @@ -using Biskilog_Accounting.Shared.CustomModels; -using Biskilog_Accounting.Shared.Interfaces; -using Biskilog_Accounting.Shared.POSModels; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using System.Runtime.InteropServices; - -namespace Biskilog_Accounting.Server.SyncControllers -{ - [Route("api/[controller]")] - [ApiController] - public class SyncCompanyInfoController : ControllerBase - { - private readonly ISalesInterface m_salesService; - private readonly ICustomer m_customer; - private readonly IUser m_users; - private readonly ICompanyInfo m_companyInfo; - public SyncCompanyInfoController(ISalesInterface a_salesService, ICustomer customer, IUser users,ICompanyInfo a_companyInfo) - { - m_salesService = a_salesService; - m_customer = customer; - m_users = users; - m_companyInfo = a_companyInfo; - } - // GET: api/ - [Authorize] - [HttpGet, Route("lastsyncdate/{a_tableName}")] - public DateTime GetLastSyncDate(string a_tableName) - { - return m_salesService.GetLastSyncDate(a_tableName); - } - // Post: api/ - [Authorize] - [HttpPost, Route("setsyncdate")] - public void SetLastSyncDate(SyncTimestamp a_timestamp) - { - m_salesService.SetLastSyncDate(a_timestamp.TableName, a_timestamp.Timestamp); - } - // POST api/ - /// - /// Endpoint to publish a collection of SystemUserRoles rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/SystemRoles")] - public async Task SyncSyatemRolesAsync(List a_item) - { - await m_companyInfo.SyncSystemRoles(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblDriver rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblDriver")] - public async Task SyncDriversAsync(List a_item) - { - await m_companyInfo.SyncDriverDetails(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of CompanyDetails rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblcompanydetails")] - public async Task SyncCompanyAsync(List a_item) - { - await m_companyInfo.SyncCompanyDetails(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblUsers rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblusers")] - public async Task SyncUsersAsync(List a_item) - { - await m_users.SyncUserAsync(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Trucks rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tbltrucks")] - public async Task SyncTrucksAsync(List a_item) - { - await m_companyInfo.SyncTrucks(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblBranch rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblbranch")] - public async Task SyncBranchAsync(List a_item) - { - await m_companyInfo.SyncBranches(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblCustomers rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblcustomers")] - public async Task SyncCustomersAsync(List a_item) - { - await m_customer.SyncCustomers(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblTruck Inventory rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tbltruckinventory")] - public async Task SyncTruckInventoryAsync(List a_item) - { - await m_companyInfo.SyncTruckInventory(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblTruckAssignment rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblTruckAssignment")] - public async Task SyncTruckAssignmentSync(List a_item) - { - await m_companyInfo.SyncTruckAssignments(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblDriverMapping rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tbldrivermappings")] - public async Task SyncTruckDriverMappingSync(List a_item) - { - await m_companyInfo.SyncTruckMappings(a_item); - } - } -} diff --git a/Server/SyncControllers/SyncProductsController.cs b/Server/SyncControllers/SyncProductsController.cs deleted file mode 100644 index b91f3cb..0000000 --- a/Server/SyncControllers/SyncProductsController.cs +++ /dev/null @@ -1,145 +0,0 @@ -using Biskilog_Accounting.Server.Services; -using Biskilog_Accounting.Shared.CustomModels; -using Biskilog_Accounting.Shared.Interfaces; -using Biskilog_Accounting.Shared.POSModels; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - -namespace Biskilog_Accounting.Server.SyncControllers -{ - [Route("api/[controller]")] - [ApiController] - public class SyncProductsController : ControllerBase - { - private readonly IProduct m_productService; - public SyncProductsController(IProduct a_productService) - { - m_productService = a_productService; - } - // GET: api/ - [Authorize] - [HttpGet, Route("lastsyncdate/{a_tableName}")] - public DateTime GetLastSyncDate(string a_tableName) - { - return m_productService.GetLastSyncDate(a_tableName); - } - // Post: api/ - [Authorize] - [HttpPost, Route("setsyncdate")] - public void SetLastSyncDate(SyncTimestamp a_timestamp) - { - m_productService.SetLastSyncDate(a_timestamp.TableName, a_timestamp.Timestamp); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblProduct rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblProducts")] - public async Task SyncProductsAsync(List a_item) - { - await m_productService.SyncProducts(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblInventory rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblInventory")] - public async Task SyncInventoryAsync(List a_item) - { - await m_productService.SyncInventory(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Restock rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblRestock")] - public async Task SyncRestockAsync(List a_item) - { - await m_productService.SyncRestockAsync(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblInventoryEntries rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblInventoryentry")] - public async Task SyncInventoryEntriesAsync(List a_item) - { - await m_productService.SyncInventoryEntries(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of PriceChanges rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tlpricechanges")] - public async Task SyncPriceChangesAsync(List a_item) - { - await m_productService.SyncPriceChanges(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of ProductAltUnit rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblProductAltUnit")] - public async Task SyncProductAltUnitAsync(List a_item) - { - await m_productService.SyncProductAltUnit(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TbStock rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblStock")] - public async Task SyncStockAsync(List a_item) - { - await m_productService.SyncStockAsync(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblBrands rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblbrands")] - public async Task SyncBrandsAsync(List a_item) - { - await m_productService.SyncBrandsAsync(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblCategory rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblCategories")] - public async Task SyncCategoriesAsync(List a_item) - { - await m_productService.SyncCategoriesAsync(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of UnitOfMeasure rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblunitofmeasure")] - public async Task SyncUnitMeasureAsync(List a_item) - { - await m_productService.SyncUnitOfMeasureAsync(a_item); - } - } -} diff --git a/Server/SyncControllers/SyncSalesController.cs b/Server/SyncControllers/SyncSalesController.cs deleted file mode 100644 index 437da37..0000000 --- a/Server/SyncControllers/SyncSalesController.cs +++ /dev/null @@ -1,145 +0,0 @@ -using Biskilog_Accounting.Shared.CustomModels; -using Biskilog_Accounting.Shared.Interfaces; -using Biskilog_Accounting.Shared.POSModels; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 - -namespace Biskilog_Accounting.Server.SyncControllers -{ - [Route("api/[controller]")] - [ApiController] - public class SyncSalesController : ControllerBase - { - private readonly ISalesInterface m_salesService; - public SyncSalesController(ISalesInterface a_salesService) - { - m_salesService = a_salesService; - } - // GET: api/ - [Authorize] - [HttpGet, Route("lastsyncdate/{a_tableName}")] - public DateTime GetLastSyncDate(string a_tableName) - { - return m_salesService.GetLastSyncDate(a_tableName); - } - // Post: api/ - [Authorize] - [HttpPost, Route("setsyncdate")] - public void SetLastSyncDate(SyncTimestamp a_timestamp) - { - m_salesService.SetLastSyncDate(a_timestamp.TableName, a_timestamp.Timestamp); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblCart rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblCart")] - public async Task SyncSalesAsync(List a_item) - { - await m_salesService.SyncCart(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblCancelledTransation rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblcancelledtransaction")] - public async Task SyncCancelledTransactionAsync(List a_item) - { - await m_salesService.SyncCancelledTransaction(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of TblInvoice rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblinvoice")] - public async Task SyncInvoiceAsync(List a_item) - { - await m_salesService.SyncInvoice(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of CreditPurchase rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblCreditpurchase")] - public async Task SyncCreditPurchaseAsync(List a_item) - { - await m_salesService.SyncCreditPurchase(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Customer Account rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblCustomerAccount")] - public async Task SyncCustomerAccountAsync(List a_item) - { - await m_salesService.SyncCustomerAccount(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Customer Purchase rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/CustomerPurchase")] - public async Task SyncCustomerPurchaseAsync(List a_item) - { - await m_salesService.SyncCustomerPurchase(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Discount logs rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/DiscountLogs")] - public async Task SyncDiscountLogsAsync(List a_item) - { - await m_salesService.SyncDiscountLogs(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Delivery Head rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblDeliveryhead")] - public async Task SyncDeliveryHeadAsync(List a_item) - { - await m_salesService.SyncDeliveryHead(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Delivery Details rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblDeliverydetails")] - public async Task SyncDeliveryDetailsAsync(List a_item) - { - await m_salesService.SyncDeliveryDetails(a_item); - } - // POST api/ - /// - /// Endpoint to publish a collection of Delivery Recipient rows to the cloud - /// - /// - [Authorize] - [HttpPost, Route("publish/tblDeliveryrecipient")] - public async Task SyncDeliveryRecipientAsync(List a_item) - { - await m_salesService.SyncDeliveryRecipients(a_item); - } - } -} diff --git a/Shared/Interfaces/ICompanyInfo.cs b/Shared/Interfaces/ICompanyInfo.cs index 450ff39..66fb19b 100644 --- a/Shared/Interfaces/ICompanyInfo.cs +++ b/Shared/Interfaces/ICompanyInfo.cs @@ -14,15 +14,5 @@ namespace Biskilog_Accounting.Shared.Interfaces Task> GetBranches(); string GetCompanyName(); string GetBranchName(string a_branchId); - Task SyncBranches(List a_branches); - Task SyncCompanyDetails(List a_details); - Task SyncDriverDetails(List a_details); - Task SyncSystemRoles(List a_roles); - Task SyncTrucks(List a_trucks); - Task SyncTruckAssignments(List a_assignments); - Task SyncTruckMappings(List a_mapping); - Task SyncTruckInventory(List a_inventories); - DateTime GetLastSyncDate(string a_tablename); - void SetLastSyncDate(string a_tableName, DateTime a_timestamp); } } diff --git a/Shared/Interfaces/ICustomer.cs b/Shared/Interfaces/ICustomer.cs index 0c5ab90..4039c2d 100644 --- a/Shared/Interfaces/ICustomer.cs +++ b/Shared/Interfaces/ICustomer.cs @@ -7,6 +7,5 @@ namespace Biskilog_Accounting.Shared.Interfaces { IEnumerable FetchCustomers(); Task> GetCustomers(); - Task SyncCustomers(List a_details); } } diff --git a/Shared/Interfaces/IProducts.cs b/Shared/Interfaces/IProducts.cs index 871ba67..b5f5aa7 100644 --- a/Shared/Interfaces/IProducts.cs +++ b/Shared/Interfaces/IProducts.cs @@ -28,17 +28,5 @@ namespace Biskilog_Accounting.Shared.Interfaces event EventHandler UnitsChanged; event EventHandler BrandsChanged; event EventHandler CategoriesChanged; - Task SyncProducts(List a_item); - Task SyncInventory(List a_item); - Task SyncInventoryEntries(List a_item); - Task SyncPriceChanges(List a_items); - Task SyncProductAltUnit(List a_items); - Task SyncRestockAsync(List a_items); - Task SyncUnitOfMeasureAsync(List a_items); - Task SyncStockAsync(List a_items); - Task SyncBrandsAsync(List a_items); - Task SyncCategoriesAsync(List a_items); - DateTime GetLastSyncDate(string a_tablename); - void SetLastSyncDate(string a_tableName, DateTime a_timestamp); } } diff --git a/Shared/Interfaces/ISalesHub.cs b/Shared/Interfaces/ISalesHub.cs deleted file mode 100644 index bb704e3..0000000 --- a/Shared/Interfaces/ISalesHub.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Biskilog_Accounting.Shared.CustomModels; - -namespace Biskilog_Accounting.Shared.Interfaces -{ - public interface ISalesHub - { - Task TransactionMade(SaleItem a_transaction); - Task JoinCompanyGroup(); - } -} diff --git a/Shared/Interfaces/ISalesInterface.cs b/Shared/Interfaces/ISalesInterface.cs index 72dc9e5..03801c4 100644 --- a/Shared/Interfaces/ISalesInterface.cs +++ b/Shared/Interfaces/ISalesInterface.cs @@ -17,18 +17,6 @@ namespace Biskilog_Accounting.Shared.Interfaces Task FetchReceipt(string a_receiptId); IEnumerable GetReceipt(string a_receiptId); Task> GetReceiptDetail(string a_receiptId); - Task SyncCart(List a_item); - Task SyncCancelledTransaction(List a_item); - Task SyncCreditPurchase(List a_item); - Task SyncCustomerAccount(List a_customerAccounts); - Task SyncCustomerPurchase(List a_customerPurchase); - Task SyncDiscountLogs(List a_discountLog); - Task SyncDeliveryDetails(List a_details); - Task SyncDeliveryHead(List a_heads); - Task SyncDeliveryRecipients(List a_recipients); - Task SyncInvoice(List a_invoice); - DateTime GetLastSyncDate(string a_tablename); - void SetLastSyncDate(string a_tableName, DateTime a_timestamp); event EventHandler TransactionsChanged; event EventHandler FetchComplete; event EventHandler FetchStart; diff --git a/Shared/Interfaces/IUser.cs b/Shared/Interfaces/IUser.cs index 8b1b712..1318c18 100644 --- a/Shared/Interfaces/IUser.cs +++ b/Shared/Interfaces/IUser.cs @@ -11,6 +11,5 @@ namespace Biskilog_Accounting.Shared.Interfaces { IEnumerable FetchUsers(); Task> GetUsers(); - Task SyncUserAsync(List a_users); } }