public ActionResult Save(LayAwayTransactionViewModel vm) { var LayAinDb = _context.LayAwayTransactions.SingleOrDefault(c => c.Id == vm.LayAwayTransaction.Id); LayAinDb.CustomerId = vm.LayAwayTransaction.CustomerId; LayAinDb.TotalPaidAmount = vm.LayAwayTransactionReceipt.AmountPaid; LayAinDb.ProductId = vm.LayAwayTransaction.ProductId; LayAinDb.Remarks = vm.LayAwayTransaction.Remarks; LayAinDb.RemainingBalance = vm.LayAwayTransaction.TotalAmount - vm.LayAwayTransactionReceipt.AmountPaid; vm.LayAwayTransactionReceipt.DateTransaction = DateTime.Now; vm.LayAwayTransactionReceipt.LayAwayTransactionId = vm.LayAwayTransaction.Id; _context.LayAwayTransactionReceipts.Add(vm.LayAwayTransactionReceipt); var temp = _context.TempCarts; foreach (var d in temp.ToList()) { _context.TempCarts.Remove(_context.TempCarts.SingleOrDefault(c => c.Id == d.Id)); } _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult LayAwayTransactionSummary(string layAwayId) { var layAwayTransaction = _context.LayAwayTransactions.SingleOrDefault(c => c.Id == layAwayId); var customer = _context.Customers.SingleOrDefault(c => c.Id == layAwayTransaction.CustomerId); var product = _context.Products.SingleOrDefault(p => p.Id == layAwayTransaction.ProductId); var viewModel = new LayAwayTransactionViewModel { LayAwayTransaction = layAwayTransaction, Customer = customer, Product = product }; return(View(viewModel)); }
public ActionResult Details(string id) { var transact = _context.LayAwayTransactions.SingleOrDefault(c => c.Id == id); var customer = _context.Customers.SingleOrDefault(c => c.Id == transact.CustomerId); var product = _context.Products.SingleOrDefault(c => c.Id == transact.ProductId); var voidItems = _context.LayAwayTransactionReceipts.Where(c => c.LayAwayTransactionId == id); /* var product = new Product();*/ ViewData["ListItem"] = voidItems.ToList(); var vm = new LayAwayTransactionViewModel() { LayAwayTransaction = transact, Product = product, Customer = customer, }; return(View(vm)); }