public ActionResult Delete([DataSourceRequest] DataSourceRequest request, UserEditModel user) { var existingUser = this.db.AppUsers.All().FirstOrDefault(u => u.Id == user.Id); if (existingUser != null) { this.db.AppUsers.Delete(existingUser); } return Json(new[] { user }.ToDataSourceResult(request, ModelState)); }
public ActionResult Update([DataSourceRequest] DataSourceRequest request, UserEditModel user) { var existingUser = this.db.AppUsers.All().FirstOrDefault(u => u.Id == user.Id); if (existingUser != null && ModelState.IsValid) { existingUser.FullName = user.FullName; existingUser.Email = user.Email; existingUser.AboutMe = user.AboutMe; this.db.SaveChanges(); } return Json(new[] { user }.ToDataSourceResult(request, ModelState)); }