public ActionResult Edit(int id, ResourceEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ResourceId != id) { ModelState.AddModelError("", "Sorry, looks like we didn't find a Resource with that Id."); return(View(model)); } var service = new ResourceServices(); if (service.UpdateResource(model)) { TempData["SaveResult"] = "Your resource has been updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Resource could not be updated."); return(View(model)); }