public ActionResult EditPost(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var locationToUpdate = _locationmanager.SelectList(x => x.Id == id).FirstOrDefault(); if (TryUpdateModel(locationToUpdate, "", new string[] { "LocationName", "Description", "Date" })) { try { _locationmanager.Edit(locationToUpdate); _locationmanager.SaveChanges(); TempData["Success"] = "Edited Successfully!"; return(RedirectToAction("Index")); } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } } return(View(locationToUpdate)); }