public ActionResult Create(Product_Info product_info) { product_info.created_by = 1; product_info.created_date = System.DateTime.Now; product_info.active_flag = true; db.Product_Info.Add(product_info); db.SaveChanges(); ViewBag.category_id = new SelectList(db.Categories.Where(x=>x.active_flag==true), "category_id", "category_name", product_info.category_id); ViewBag.sub_category_id = new SelectList(db.Sub_Category.Where(x=>x.active_flag==true), "sub_category_id", "sub_category_name", product_info.sub_category_id); ViewBag.supplier_info_id = new SelectList(db.Supplier_Info.Where(x=>x.active_flag==true), "supplier_info_id", "supplier_name", product_info.supplier_info_id); ViewBag.unit_id = new SelectList(db.Units.Where(x=>x.active_flag==true), "unit_id", "unit_name"); return RedirectToAction("Index"); }
public ActionResult Edit(Product_Info product_info) { if (ModelState.IsValid) { db.Entry(product_info).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.category_id = new SelectList(db.Categories.Where(x => x.active_flag == true), "category_id", "category_name", product_info.category_id); ViewBag.sub_category_id = new SelectList(db.Sub_Category.Where(x => x.active_flag == true), "sub_category_id", "sub_category_name", product_info.sub_category_id); ViewBag.supplier_info_id = new SelectList(db.Supplier_Info.Where(x => x.active_flag == true), "supplier_info_id", "supplier_name", product_info.supplier_info_id); ViewBag.unit_id = new SelectList(db.Units.Where(x => x.active_flag == true), "unit_id", "unit_name"); return View(product_info); }