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); } } }