internal void LoadSales() { this.Sales = new List <SaleViewModel>(); foreach (var item in IMDAL.GetSales()) { this.Sales.Add(new SaleViewModel(item)); } }
internal void LoadProducts() { this.Products = new List <InventoryViewModel>(); foreach (var item in IMDAL.GetAllProducts()) { this.Products.Add(new InventoryViewModel(item)); } }
public ActionResult Sale(SaleViewModel vm) { try { vm.InvoiceNumber = IMDAL.GenerateInvoiceNumber(); IMDAL.AddUpdate <Sale>(vm.ToEntity()); } catch (Exception e) { } return(RedirectToAction("Sale")); }
public SaleViewModel(Sale dbSale) { this.Id = dbSale.Id; this.Amount = dbSale.Amount; this.InvoiceNumber = dbSale.InvoiceNumber; this.ProductId = dbSale.ProductId; this.ProductName = IMDAL.FindProductName(this.ProductId.GetValueOrDefault()); this.Quantity = dbSale.Quantity; this.SoldBy = dbSale.SoldBy; this.SoldOn = dbSale.SoldOn.GetValueOrDefault().ToLocalTime(); this.SoldTo = dbSale.SoldTo; }
public InventoryViewModel(Product dbObj) { this.Id = dbObj.Id; this.Price = dbObj.Price; this.ProductName = dbObj.ProductName; this.Quantity = dbObj.Quantity; this.Remarks = dbObj.Remarks; this.VendorName = dbObj.VendorName; this.Sold = IMDAL.FindStockLeft(this.Id); this.InStock = this.Quantity.GetValueOrDefault() - this.Sold; }
public ActionResult CalculateAmount(long productId, long quantity) { decimal amount = 0; try { amount = IMDAL.FindAmount(productId, quantity); } catch (Exception e) { amount = 0; } return(Content(amount.ToString())); }
public System.Collections.IEnumerable LoadProducts() { List <SelectListItem> ddl = new List <SelectListItem>(); foreach (var item in IMDAL.GetAllProducts()) { ddl.Add(new SelectListItem() { Text = item.ProductName, Value = item.Id.ToString() }); } return(ddl); }
public ActionResult AddInventory(InventoryViewModel vm) { try { IMDAL.AddUpdate <Product>(new Product() { Price = vm.Price, ProductName = vm.ProductName, Quantity = vm.Quantity, Remarks = vm.Remarks, VendorName = vm.VendorName }); } catch (Exception e) { } return(RedirectToAction("Inventory")); }