The cloud manager acts as an intermediary for syncing between the local biskilog server manager and the biskilog accounting web application
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.

151 lines
5.7 KiB

using Cloud_Manager.Models.CustomModels;
using Cloud_Manager.Models.Interfaces;
using Cloud_Manager.Models.POSModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Runtime.InteropServices;
namespace Cloud_Manager.Controllers.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);
}
}
}