public TransactionsViewModel(IRegionManager regionManager, SaleTransactionModel saleTransaction, PurchaseTransactionModel purchaseTransaction) { _saleTransaction = saleTransaction; _purchaseTransaction = purchaseTransaction; FilterTxnHistory("0"); DateFilterCmd = new DelegateCommand <string>(FilterTxnHistory); }
public AddPaymentViewModel(IRegionManager regionManager, SaleTransactionModel saleTransaction) { _regionManager = regionManager; _saleTransaction = saleTransaction; CashPaymentCmd = new DelegateCommand <string>(CashPayment); NotificationRequest = new InteractionRequest <INotification>(); PaymentAmount = _saleTransaction.sale.TransactionTotal; }
public SaleViewModel(IRegionManager regionManager, SaleTransactionModel saleTransaction, ProductModel products) { _regionManager = regionManager; _saleTransaction = saleTransaction; _products = products; Total = "0.00"; SelectedUOMIndex = 0; CheckoutCmd = new DelegateCommand(Checkout); CancelSaleCmd = new DelegateCommand(CancelSale); AddProductCmd = new DelegateCommand <Product>(AddProduct); RemoveProductCmd = new DelegateCommand <int?>(RemoveProduct); SearchProductByNameCmd = new DelegateCommand <string>(SearchProductByName); SearchProductByIdCmd = new DelegateCommand <string>(SearchProductById); //RaiseNotificationCmd = new DelegateCommand(RaiseNotification); NotificationRequest = new InteractionRequest <INotification>(); }
public int InsertTransaction(SaleTransactionModel sale) { const string saleInsert = "INSERT INTO [dbo].[SalesTransaction] ([ProductID], [PersonID], [SalesDataTime], [PQuantity])" + " VALUES (@ProductId, @PersonId, @SaleTime, @Quantity) select SCOPE_IDENTITY() as id"; SqlConnection conn = null; try { // Get Sql Connection conn = GetConnection(_connStrKey); conn.Open(); // Insert into Person table var sqlCmd = new SqlCommand(saleInsert, conn); sqlCmd.Parameters.AddWithValue("@ProductId", sale.ProductId); sqlCmd.Parameters.AddWithValue("@PersonId", sale.PersonId); sqlCmd.Parameters.AddWithValue("@SaleTime", sale.TransactionTime); sqlCmd.Parameters.AddWithValue("@Quantity", sale.Quantity); var sqlReader = sqlCmd.ExecuteReader(); sqlReader.Read(); var saleId = Convert.ToInt32(sqlReader[0].ToString()); sqlReader.Close(); return(saleId); } catch (Exception e) { throw new Exception("Error inserting transaction into database: " + e.Message, e); } finally { if (conn != null && conn.State == ConnectionState.Open) { conn.Close(); } } }
public IActionResult BuyProduct(string PID) { InitView(); if (ViewBag.ShowLoginForm) { ViewBag.LoginMessage = "User not logged in."; return(View("Index")); } var productDal = new ProductDAL(_configuration); var product = productDal.GetProduct(Convert.ToInt32(PID)); productDal.UpdateInventory(product, 1); var personDal = new PersonDAL(_configuration); var person = personDal.GetPerson(HttpContext.Session.GetString(personIdKey)); var transactionDal = new TransactionDAL(_configuration); var txn = new SaleTransactionModel() { PersonId = person.PersonId, ProductId = product.ProductId, TransactionTime = DateTime.Now, Quantity = 1 }; var tranId = transactionDal.InsertTransaction(txn); var purchase = new PurchaseModel() { Person = person, Product = product, SalesId = tranId }; return(View(purchase)); }