public ActionResult addOrders(List<Out_Of_Stock_Transactions_vw> list = null) { foreach (var i in list) { int val = 1; bool y = Convert.ToBoolean(val); if (i.active_flag == y) { var data1 = db.Product_Purchase.Where(x=>x.product_info_id==i.product_info_id && x.pt_id==null).FirstOrDefault(); if (data1 != null) { Product_Purchase pp1 = db.Product_Purchase.Find(data1.product_purchase_id); pp1.purchase_qty = i.product_qty; db.Entry(pp1).State = EntityState.Modified; } else { Product_Purchase pp = new Product_Purchase(); pp.product_info_id = i.product_info_id; pp.purchase_qty = i.product_qty; pp.purchase_new_price = i.product_orig_price; pp.active_flag = true; pp.pt_id = null; db.Product_Purchase.Add(pp); } } } db.SaveChanges(); ////getting data from Product_Purchase table //var data = db.Current_Order_Items.Where(x => x.active_flag==true).ToList(); //return View("Current_Order_Items",data); return RedirectToAction("Current_Order_Items"); }
public ActionResult AddNewItem(int product_info_id = 0, int purchase_qty = 0) { var data1 = db.Product_Purchase.Where(x => x.product_info_id == product_info_id && x.pt_id == null).FirstOrDefault(); if (data1 != null) { Product_Purchase pp1 = db.Product_Purchase.Find(data1.product_purchase_id); pp1.purchase_qty = purchase_qty; db.Entry(pp1).State = EntityState.Modified; } else { //getting the original price first from Product_Info table Product_Info pi = db.Product_Info.Find(product_info_id); Product_Purchase pp = new Product_Purchase(); pp.product_info_id = product_info_id; pp.purchase_qty = purchase_qty; pp.purchase_new_price = pi.product_orig_price; pp.active_flag = true; pp.pt_id = null; db.Product_Purchase.Add(pp); } db.SaveChanges(); return RedirectToAction("Current_Order_Items"); }
public ActionResult Modify_Purchase_Item(Product_Purchase pp) { db.Entry(pp).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Current_Order_Items"); }
public ActionResult Edit(Product_Purchase product_purchase) { if (ModelState.IsValid) { db.Entry(product_purchase).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.product_info_id = new SelectList(db.Product_Info, "product_info_id", "product_desc", product_purchase.product_info_id); return View(product_purchase); }
public ActionResult Create(Product_Purchase product_purchase) { if (ModelState.IsValid) { db.Product_Purchase.Add(product_purchase); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.product_info_id = new SelectList(db.Product_Info, "product_info_id", "product_desc", product_purchase.product_info_id); return View(product_purchase); }