public ActionResult GridViewPartialEmployeeUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Northwind.DevExpress.UI.Models.Employee item) { var model = db.Employees; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.EmployeeID == item.EmployeeID); if (modelItem != null) { this.UpdateModel(modelItem); db.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewPartialEmployee", model.ToList())); }
public ActionResult GridViewPartialEmployeeAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Northwind.DevExpress.UI.Models.Employee item) { var model = db.Employees; if (ModelState.IsValid) { try { model.Add(item); db.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewPartialEmployee", model.ToList())); }