public ActionResult EditItem(ItemViewModel itemViewModel) { using (var depCalcContext = new DepCalcContext()) { var item = depCalcContext.Items.SingleOrDefault(p => p.ItemId == itemViewModel.ItemId); if (item != null) { item.ItemName = itemViewModel.ItemName; item.GenLedger = itemViewModel.GenLedger; item.QtyServUnit = itemViewModel.QtyServUnit; item.QtyCount = itemViewModel.QtyCount; item.CountUnit = itemViewModel.CountUnit; item.PurchUnit = itemViewModel.PurchUnit; item.SellUnit = itemViewModel.SellUnit; item.CountFrequency = itemViewModel.CountFrequency; item.StandCost = itemViewModel.StandCost; depCalcContext.SaveChanges(); return(RedirectToAction("Index")); } } return(new HttpNotFoundResult()); }
public ActionResult DeleteItem(ItemViewModel itemViewModel) { using (var depCalcContext = new DepCalcContext()) { var item = depCalcContext.Items.SingleOrDefault(p => p.ItemId == itemViewModel.ItemId); if (item != null) { depCalcContext.Items.Remove(item); depCalcContext.SaveChanges(); return(RedirectToAction("Index")); } } return(new HttpNotFoundResult()); }
public ActionResult AddItem(ItemViewModel itemViewModel) { using (var depCalcContext = new DepCalcContext()) { var item = new Item { //ItemId = nextItemId, ItemName = itemViewModel.ItemName, GenLedger = itemViewModel.GenLedger, QtyServUnit = itemViewModel.QtyServUnit, QtyCount = itemViewModel.QtyCount, CountUnit = itemViewModel.CountUnit, PurchUnit = itemViewModel.PurchUnit, SellUnit = itemViewModel.SellUnit, CountFrequency = itemViewModel.CountFrequency, StandCost = itemViewModel.StandCost }; depCalcContext.Items.Add(item); depCalcContext.SaveChanges(); } return(RedirectToAction("Index")); }