public ActionResult Index(ArticleGroupModelView model) { try { List <ArticleGroup> list = db.ArticleGroups.ToList(); if (model.Id > 0) { //update ArticleGroup conf = db.ArticleGroups.SingleOrDefault(x => x.ArticleGroupId == model.Id); conf.ArticleGroupId = model.Id; conf.Name = model.Name; conf.Description = model.Description; db.SaveChanges(); } else { //Insert ArticleGroup manu = new ArticleGroup { Name = model.Name, Description = model.Description }; db.ArticleGroups.Add(manu); db.SaveChanges(); } return(View(model)); } catch (Exception ex) { throw ex; } }
public ActionResult AddEditArticleGroup(int Id) { List <ArticleGroup> list = db.ArticleGroups.ToList(); ArticleGroupModelView model = new ArticleGroupModelView(); if (Id > 0) { ArticleGroup manu = db.ArticleGroups.SingleOrDefault(x => x.ArticleGroupId == Id); model.Id = manu.ArticleGroupId; model.Name = manu.Name; model.Description = manu.Description; } return(PartialView("Partial2", model)); }