|
|
|
using Biskilog_Cloud.Shared.CustomModels;
|
|
|
|
using Biskilog_Cloud.Shared.Interfaces;
|
|
|
|
using Biskilog_Cloud.Shared.Models;
|
|
|
|
using Dapper;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using System.Data;
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
|
|
|
namespace ServerManager.ServiceRepo
|
|
|
|
{
|
|
|
|
public class SalesService : ISalesInterface
|
|
|
|
{
|
|
|
|
private readonly BiskPosContext m_context;
|
|
|
|
private readonly string m_connection;
|
|
|
|
|
|
|
|
public SalesService(BiskPosContext a_context, IConfiguration configuration)
|
|
|
|
{
|
|
|
|
m_context = a_context;
|
|
|
|
m_connection = configuration.GetConnectionString("connection")!.ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public event EventHandler TransactionsChanged;
|
|
|
|
public event EventHandler FetchComplete;
|
|
|
|
public event EventHandler FetchStart;
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblCancelledTransaction>> FetchCancelledTransaction(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "tblcancelledtransactions",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblCancelledTransaction> result = (await dbConnection.QueryAsync<TblCancelledTransaction>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblCart>> FetchCartTbl(DateTime a_lastSync,string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "tblcart",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblCart> result = (await dbConnection.QueryAsync<TblCart>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<CreditPurchase>> FetchCreditPurchase(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "CreditPurchases",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<CreditPurchase> result = (await dbConnection.QueryAsync<CreditPurchase>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<CustomerAccount>> FetchCustomerAccount(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "customeraccounts",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<CustomerAccount> result = (await dbConnection.QueryAsync<CustomerAccount>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblCustomerPurchase>> FetchCustomerPurchase(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "tblcustomerpurchases",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblCustomerPurchase> result = (await dbConnection.QueryAsync<TblCustomerPurchase>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblDeliveryDetail>> FetchDeliveryDetails(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "tbldeliverydetails",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblDeliveryDetail> result = (await dbConnection.QueryAsync<TblDeliveryDetail>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblDeliveryHead>> FetchDeliveryHead(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "TblDeliveryHeads",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblDeliveryHead> result = (await dbConnection.QueryAsync<TblDeliveryHead>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblDeliveryRecipient>> FetchDeliveryRecipients(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "TblDeliveryRecipients",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblDeliveryRecipient> result = (await dbConnection.QueryAsync<TblDeliveryRecipient>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblDiscountLog>> FetchDiscountLogs(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "TblDiscountLogs",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblDiscountLog> result = (await dbConnection.QueryAsync<TblDiscountLog>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TblInvoice>> FetchInvoice(DateTime a_lastSync, string a_branch)
|
|
|
|
{
|
|
|
|
using (IDbConnection dbConnection = new SqlConnection(m_connection))
|
|
|
|
{
|
|
|
|
dbConnection.Open();
|
|
|
|
|
|
|
|
// Using Dapper to call a stored procedure with parameters
|
|
|
|
var parameters = new
|
|
|
|
{
|
|
|
|
a_tableName = "TblInvoice",
|
|
|
|
a_branchId = a_branch,
|
|
|
|
lastModified = a_lastSync
|
|
|
|
};
|
|
|
|
List<TblInvoice> result = (await dbConnection.QueryAsync<TblInvoice>(
|
|
|
|
"FetchTableRows",
|
|
|
|
parameters,
|
|
|
|
commandType: CommandType.StoredProcedure)).AsList();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Task FetchReceipt(string a_receiptId)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Task FetchRecentTransaction(int a_limit)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Task FetchTransaction(DateTime a_start, DateTime a_end)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<SaleItem> GetReceipt(string a_receiptId)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Task<IEnumerable<TblCart>> GetReceiptDetail(string a_receiptId)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<SaleItem> GetRecentTransaction()
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<SaleItem> GetTransactions(DateTime a_start, DateTime a_end)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|