Browse Source

Removed all sync controllers from Biskilog account backend

pull/14/head
Benjamin Arhen 1 year ago
parent
commit
90bdb526ab
  1. 18
      Server/CloudHubs/SalesHub.cs
  2. 19
      Server/Services/SalesService.cs
  3. 151
      Server/SyncControllers/SyncCompanyInfoController.cs
  4. 145
      Server/SyncControllers/SyncProductsController.cs
  5. 145
      Server/SyncControllers/SyncSalesController.cs
  6. 10
      Shared/Interfaces/ICompanyInfo.cs
  7. 1
      Shared/Interfaces/ICustomer.cs
  8. 12
      Shared/Interfaces/IProducts.cs
  9. 10
      Shared/Interfaces/ISalesHub.cs
  10. 12
      Shared/Interfaces/ISalesInterface.cs
  11. 1
      Shared/Interfaces/IUser.cs

18
Server/CloudHubs/SalesHub.cs

@ -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<ISalesHub>
{
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);
}
}
}

19
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<SalesHub, ISalesHub> 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<SalesHub, ISalesHub> 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)
});
}
}

151
Server/SyncControllers/SyncCompanyInfoController.cs

@ -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/<SyncCompanyInfoController>
[Authorize]
[HttpGet, Route("lastsyncdate/{a_tableName}")]
public DateTime GetLastSyncDate(string a_tableName)
{
return m_salesService.GetLastSyncDate(a_tableName);
}
// Post: api/<SyncCompanyInfoController>
[Authorize]
[HttpPost, Route("setsyncdate")]
public void SetLastSyncDate(SyncTimestamp a_timestamp)
{
m_salesService.SetLastSyncDate(a_timestamp.TableName, a_timestamp.Timestamp);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of SystemUserRoles rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/SystemRoles")]
public async Task SyncSyatemRolesAsync(List<Systemuserrole> a_item)
{
await m_companyInfo.SyncSystemRoles(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of TblDriver rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblDriver")]
public async Task SyncDriversAsync(List<Tbldriver> a_item)
{
await m_companyInfo.SyncDriverDetails(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of CompanyDetails rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblcompanydetails")]
public async Task SyncCompanyAsync(List<Tblcompanydetail> a_item)
{
await m_companyInfo.SyncCompanyDetails(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of TblUsers rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblusers")]
public async Task SyncUsersAsync(List<Tbluser> a_item)
{
await m_users.SyncUserAsync(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of Trucks rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tbltrucks")]
public async Task SyncTrucksAsync(List<Tbltruck> a_item)
{
await m_companyInfo.SyncTrucks(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of TblBranch rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblbranch")]
public async Task SyncBranchAsync(List<Tblbranch> a_item)
{
await m_companyInfo.SyncBranches(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of TblCustomers rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblcustomers")]
public async Task SyncCustomersAsync(List<Tblcustomer> a_item)
{
await m_customer.SyncCustomers(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of TblTruck Inventory rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tbltruckinventory")]
public async Task SyncTruckInventoryAsync(List<Tbltruckinventory> a_item)
{
await m_companyInfo.SyncTruckInventory(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of TblTruckAssignment rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblTruckAssignment")]
public async Task SyncTruckAssignmentSync(List<Tbltruckassignment> a_item)
{
await m_companyInfo.SyncTruckAssignments(a_item);
}
// POST api/<SyncCompanyInfoController>
/// <summary>
/// Endpoint to publish a collection of TblDriverMapping rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tbldrivermappings")]
public async Task SyncTruckDriverMappingSync(List<TbltruckDrivermapping> a_item)
{
await m_companyInfo.SyncTruckMappings(a_item);
}
}
}

145
Server/SyncControllers/SyncProductsController.cs

@ -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/<SyncProductsController>
[Authorize]
[HttpGet, Route("lastsyncdate/{a_tableName}")]
public DateTime GetLastSyncDate(string a_tableName)
{
return m_productService.GetLastSyncDate(a_tableName);
}
// Post: api/<SyncProductsController>
[Authorize]
[HttpPost, Route("setsyncdate")]
public void SetLastSyncDate(SyncTimestamp a_timestamp)
{
m_productService.SetLastSyncDate(a_timestamp.TableName, a_timestamp.Timestamp);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of TblProduct rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblProducts")]
public async Task SyncProductsAsync(List<Tblproduct> a_item)
{
await m_productService.SyncProducts(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of TblInventory rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblInventory")]
public async Task SyncInventoryAsync(List<Tblinventory> a_item)
{
await m_productService.SyncInventory(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of Restock rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblRestock")]
public async Task SyncRestockAsync(List<Restocklevel> a_item)
{
await m_productService.SyncRestockAsync(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of TblInventoryEntries rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblInventoryentry")]
public async Task SyncInventoryEntriesAsync(List<Tblinventoryentry> a_item)
{
await m_productService.SyncInventoryEntries(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of PriceChanges rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tlpricechanges")]
public async Task SyncPriceChangesAsync(List<Tblpricechange> a_item)
{
await m_productService.SyncPriceChanges(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of ProductAltUnit rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblProductAltUnit")]
public async Task SyncProductAltUnitAsync(List<Productaltunit> a_item)
{
await m_productService.SyncProductAltUnit(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of TbStock rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblStock")]
public async Task SyncStockAsync(List<Tbstock> a_item)
{
await m_productService.SyncStockAsync(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of TblBrands rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblbrands")]
public async Task SyncBrandsAsync(List<Tblbrand> a_item)
{
await m_productService.SyncBrandsAsync(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of TblCategory rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblCategories")]
public async Task SyncCategoriesAsync(List<Tblcategory> a_item)
{
await m_productService.SyncCategoriesAsync(a_item);
}
// POST api/<SyncProductsController>
/// <summary>
/// Endpoint to publish a collection of UnitOfMeasure rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblunitofmeasure")]
public async Task SyncUnitMeasureAsync(List<Unitofmeasure> a_item)
{
await m_productService.SyncUnitOfMeasureAsync(a_item);
}
}
}

145
Server/SyncControllers/SyncSalesController.cs

@ -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/<SyncSalesController>
[Authorize]
[HttpGet, Route("lastsyncdate/{a_tableName}")]
public DateTime GetLastSyncDate(string a_tableName)
{
return m_salesService.GetLastSyncDate(a_tableName);
}
// Post: api/<SyncSalesController>
[Authorize]
[HttpPost, Route("setsyncdate")]
public void SetLastSyncDate(SyncTimestamp a_timestamp)
{
m_salesService.SetLastSyncDate(a_timestamp.TableName, a_timestamp.Timestamp);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of TblCart rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblCart")]
public async Task SyncSalesAsync(List<Tblcart> a_item)
{
await m_salesService.SyncCart(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of TblCancelledTransation rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblcancelledtransaction")]
public async Task SyncCancelledTransactionAsync(List<Tblcancelledtransaction> a_item)
{
await m_salesService.SyncCancelledTransaction(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of TblInvoice rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblinvoice")]
public async Task SyncInvoiceAsync(List<Tblinvoice> a_item)
{
await m_salesService.SyncInvoice(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of CreditPurchase rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblCreditpurchase")]
public async Task SyncCreditPurchaseAsync(List<Creditpurchase> a_item)
{
await m_salesService.SyncCreditPurchase(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of Customer Account rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblCustomerAccount")]
public async Task SyncCustomerAccountAsync(List<Customeraccount> a_item)
{
await m_salesService.SyncCustomerAccount(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of Customer Purchase rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/CustomerPurchase")]
public async Task SyncCustomerPurchaseAsync(List<Tblcustomerpurchase> a_item)
{
await m_salesService.SyncCustomerPurchase(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of Discount logs rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/DiscountLogs")]
public async Task SyncDiscountLogsAsync(List<Tbldiscountlog> a_item)
{
await m_salesService.SyncDiscountLogs(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of Delivery Head rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblDeliveryhead")]
public async Task SyncDeliveryHeadAsync(List<Tbldeliveryhead> a_item)
{
await m_salesService.SyncDeliveryHead(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of Delivery Details rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblDeliverydetails")]
public async Task SyncDeliveryDetailsAsync(List<Tbldeliverydetail> a_item)
{
await m_salesService.SyncDeliveryDetails(a_item);
}
// POST api/<SyncSalesController>
/// <summary>
/// Endpoint to publish a collection of Delivery Recipient rows to the cloud
/// </summary>
/// <param name="a_item"></param>
[Authorize]
[HttpPost, Route("publish/tblDeliveryrecipient")]
public async Task SyncDeliveryRecipientAsync(List<Tbldeliveryrecipient> a_item)
{
await m_salesService.SyncDeliveryRecipients(a_item);
}
}
}

10
Shared/Interfaces/ICompanyInfo.cs

@ -14,15 +14,5 @@ namespace Biskilog_Accounting.Shared.Interfaces
Task<IEnumerable<Tblbranch>> GetBranches();
string GetCompanyName();
string GetBranchName(string a_branchId);
Task SyncBranches(List<Tblbranch> a_branches);
Task SyncCompanyDetails(List<Tblcompanydetail> a_details);
Task SyncDriverDetails(List<Tbldriver> a_details);
Task SyncSystemRoles(List<Systemuserrole> a_roles);
Task SyncTrucks(List<Tbltruck> a_trucks);
Task SyncTruckAssignments(List<Tbltruckassignment> a_assignments);
Task SyncTruckMappings(List<TbltruckDrivermapping> a_mapping);
Task SyncTruckInventory(List<Tbltruckinventory> a_inventories);
DateTime GetLastSyncDate(string a_tablename);
void SetLastSyncDate(string a_tableName, DateTime a_timestamp);
}
}

1
Shared/Interfaces/ICustomer.cs

@ -7,6 +7,5 @@ namespace Biskilog_Accounting.Shared.Interfaces
{
IEnumerable<CustomerAccounts> FetchCustomers();
Task<IEnumerable<CustomerAccounts>> GetCustomers();
Task SyncCustomers(List<Tblcustomer> a_details);
}
}

12
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<Tblproduct> a_item);
Task SyncInventory(List<Tblinventory> a_item);
Task SyncInventoryEntries(List<Tblinventoryentry> a_item);
Task SyncPriceChanges(List<Tblpricechange> a_items);
Task SyncProductAltUnit(List<Productaltunit> a_items);
Task SyncRestockAsync(List<Restocklevel> a_items);
Task SyncUnitOfMeasureAsync(List<Unitofmeasure> a_items);
Task SyncStockAsync(List<Tbstock> a_items);
Task SyncBrandsAsync(List<Tblbrand> a_items);
Task SyncCategoriesAsync(List<Tblcategory> a_items);
DateTime GetLastSyncDate(string a_tablename);
void SetLastSyncDate(string a_tableName, DateTime a_timestamp);
}
}

10
Shared/Interfaces/ISalesHub.cs

@ -1,10 +0,0 @@
using Biskilog_Accounting.Shared.CustomModels;
namespace Biskilog_Accounting.Shared.Interfaces
{
public interface ISalesHub
{
Task TransactionMade(SaleItem a_transaction);
Task JoinCompanyGroup();
}
}

12
Shared/Interfaces/ISalesInterface.cs

@ -17,18 +17,6 @@ namespace Biskilog_Accounting.Shared.Interfaces
Task FetchReceipt(string a_receiptId);
IEnumerable<SaleItem> GetReceipt(string a_receiptId);
Task<IEnumerable<Tblcart>> GetReceiptDetail(string a_receiptId);
Task SyncCart(List<Tblcart> a_item);
Task SyncCancelledTransaction(List<Tblcancelledtransaction> a_item);
Task SyncCreditPurchase(List<Creditpurchase> a_item);
Task SyncCustomerAccount(List<Customeraccount> a_customerAccounts);
Task SyncCustomerPurchase(List<Tblcustomerpurchase> a_customerPurchase);
Task SyncDiscountLogs(List<Tbldiscountlog> a_discountLog);
Task SyncDeliveryDetails(List<Tbldeliverydetail> a_details);
Task SyncDeliveryHead(List<Tbldeliveryhead> a_heads);
Task SyncDeliveryRecipients(List<Tbldeliveryrecipient> a_recipients);
Task SyncInvoice(List<Tblinvoice> a_invoice);
DateTime GetLastSyncDate(string a_tablename);
void SetLastSyncDate(string a_tableName, DateTime a_timestamp);
event EventHandler TransactionsChanged;
event EventHandler FetchComplete;
event EventHandler FetchStart;

1
Shared/Interfaces/IUser.cs

@ -11,6 +11,5 @@ namespace Biskilog_Accounting.Shared.Interfaces
{
IEnumerable<Tbluser> FetchUsers();
Task<IEnumerable<Tbluser>> GetUsers();
Task SyncUserAsync(List<Tbluser> a_users);
}
}

Loading…
Cancel
Save