public JsonResult JsUpdate(Cargo cargo) { var cargoDAO = new CargoDAO(); cargoDAO.UpdateCargo(cargo); var result = new { type = "success", field = "", message = "Registro alterado com sucesso!", model = cargo }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(int id, Cargo cargo) { if (string.IsNullOrWhiteSpace(cargo.dsCargo)) { ModelState.AddModelError("dsCargo", "Informe um nome de cargo válido"); } try { if (ModelState.IsValid) { var cargoDAO = new CargoDAO(); cargoDAO.UpdateCargo(cargo); return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }