public ActionResult Index(ProductGroupModelView model) { try { List <ProductGroup> list = db.ProductGroups.ToList(); if (model.Id > 0) { //update ProductGroup conf = db.ProductGroups.SingleOrDefault(x => x.ProductGroupId == model.Id); conf.ProductGroupId = model.Id; conf.Name = model.Name; db.SaveChanges(); } else { //Insert ProductGroup manu = new ProductGroup { Name = model.Name, }; db.ProductGroups.Add(manu); db.SaveChanges(); } return(View(model)); } catch (Exception ex) { throw ex; } }
public ActionResult AddEditProductGroup(int Id) { List <ProductGroup> list = db.ProductGroups.ToList(); ProductGroupModelView model = new ProductGroupModelView(); if (Id > 0) { ProductGroup manu = db.ProductGroups.SingleOrDefault(x => x.ProductGroupId == Id); model.Id = manu.ProductGroupId; model.Name = manu.Name; } return(PartialView("Detail", model)); }