public ActionResult Edit(DependenteViewModel dependente) { if (ModelState.IsValid) { var dependenteDomain = Mapper.Map <DependenteViewModel, Dependente>(dependente); _depApp.Update(dependenteDomain); return(RedirectToAction("Index")); } ViewBag.SexoId = new SelectList(_sexoApp.GetAll(), "Id", "Descricao", dependente.SexoId); ViewBag.GrauInstrucaoId = new SelectList(_grauInstrucaoApp.GetAll(), "Id", "Descricao", dependente.GrauInstrucaoId); return(View(dependente)); }
/// <summary> /// Inserir um Dependente /// </summary> /// <param name="dependente">Dependente</param> /// <returns></returns> public ActionResult InsertDependente(DependenteViewModel dependente) { try { var dependenteDomain = Mapper.Map <DependenteViewModel, Dependente>(dependente); if (dependente.DependenteId > 0) { _dependenteApp.Update(dependenteDomain); } else { _dependenteApp.Add(dependenteDomain); } return(Json(dependenteDomain, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { erro = ex.Message }, JsonRequestBehavior.AllowGet)); } }