コード例 #1
0
        private void btnSalvarMor_Click(object sender, EventArgs e)
        {
            string erro = String.Empty;

            if (!ValidarCampos(out erro))
            {
                MessageBox.Show(erro, "Atenção");
            }

            MoradorTO moradorTO = new MoradorTO();

            moradorTO.Nome           = txtNomeMor.Text;
            moradorTO.RG             = txtRgMor.Text;
            moradorTO.CPF            = txtCpfMor.Text;
            moradorTO.Telefone       = txtTelefoneMor.Text;
            moradorTO.Celular        = txtCelularMor.Text;
            moradorTO.DataNascimento = dtNascimento.Value.Date;
            moradorTO.Email          = txtEmailMor.Text;

            MoradorService.Criar(moradorTO);

            if (!moradorTO.Valido)
            {
                MessageBox.Show(moradorTO.Mensagem, "Atenção");
                return;
            }

            this.Close();
        }
コード例 #2
0
        public ActionResult Create(MoradorVM morador)
        {
            if (ModelState.IsValid)
            {
                var moradorTO = Mapper.Map <MoradorVM, MoradorTO>(morador);

                MoradorService.Criar(moradorTO);

                Session["Mensagem"] = moradorTO.Mensagem;
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(morador));
            }
        }