public ActionResult salvar(PessoaRelacionamentoForm ViewModel) { if (!ModelState.IsValid) { return(PartialView("modal-form-cadastro", ViewModel)); } bool flagSucesso = this.OPessoaRelacionamentoBL.salvar(ViewModel.PessoaRelacionamento); if (flagSucesso) { foreach (var OArquivo in ViewModel.Arquivos) { if (OArquivo.FileUpload != null) { OArquivoUploadBL.salvarDocumento(ViewModel.PessoaRelacionamento.id, EntityTypes.PESSOADOCUMENTO_RELACIONAMENTO, OArquivo.legenda, OArquivo.FileUpload, User.idOrganizacao(), User.id()); } } this.Flash(UtilMessage.TYPE_MESSAGE_SUCCESS, UtilMessage.success("Sucesso", "Os dados foram salvos com sucesso.")); return(Json(new { error = false, ViewModel.flagRecarregar }, JsonRequestBehavior.AllowGet)); } this.Flash(UtilMessage.TYPE_MESSAGE_ERROR, UtilMessage.error("Erro", "Houve algum problema ao salvar os dados da ocorrência.")); return(PartialView("modal-form-cadastro", ViewModel)); }
public PartialViewResult modalFormCadastro(int?id, int?idPessoa) { var ViewModel = new PessoaRelacionamentoForm(); ViewModel.PessoaRelacionamento = this.OPessoaRelacionamentoBL.carregar(UtilNumber.toInt32(id)) ?? new PessoaRelacionamento() { idPessoa = idPessoa.toInt() }; ViewModel.flagRecarregar = UtilRequest.getBool("flagRecarregar") ?? false; return(PartialView(ViewModel)); }