public ActionResult Create(DependenteViewModel dependente, int PessoaId) { if (ModelState.IsValid) { var dependenteDomain = Mapper.Map <DependenteViewModel, Dependente>(dependente); dependenteDomain.PessoaId = PessoaId; _depApp.Add(dependenteDomain); return(RedirectToAction("Index", "Dependente", new { id = PessoaId })); } 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)); } }