示例#1
0
        public ActionResult CadastrarUnico(AlunoMaeEnderecoViewModel ame)
        {
            if (ModelState.IsValid)
            {
                if (CpfUtils.IsValidCPF(ame.CPF))
                {
                    var aluno = Mapper.Map <AlunoMaeEnderecoViewModel, Aluno>(ame);
                    daoMae.Inserir(Mapper.Map <AlunoMaeEnderecoViewModel, Mae>(ame));
                    aluno.IdMae = daoAluno.ObterUltimoId();

                    daoEndereco.Inserir(Mapper.Map <AlunoMaeEnderecoViewModel, Endereco>(ame));
                    aluno.IdEndereco = daoAluno.ObterUltimoId();

                    aluno.Id = Guid.NewGuid().ToString();

                    var resultado = daoAluno.Inserir(aluno);
                    if (resultado > -1)
                    {
                        return(RedirectToAction("Index", "Aluno"));
                    }
                }
                else
                {
                    ViewBag.idSerieDeIngresso = new SelectList(daoSerie.ObterTudo(), "id", "serie");
                    ModelState.AddModelError(nameof(ame.CPF), "CPF incorrecto");
                    return(View(ame));
                }
            }
            ViewBag.idSerieDeIngresso = new SelectList(daoSerie.ObterTudo(), "id", "serie");
            return(View(ame));
        }
示例#2
0
 public ActionResult Cadastrar([Bind(Include = "id,nomeCompleto,cpf,dataPreferencialPagamento")] Mae mae)
 {
     if (ModelState.IsValid)
     {
         if (CpfUtils.IsValidCPF(mae.CPF) && !daoMae.VerificarExistenciaCPF(mae.CPF))
         {
             var resultado = daoMae.Inserir(mae);
             if (resultado > -1)
             {
                 return(RedirectToAction("Index", "Mae"));
             }
         }
         else
         {
             ModelState.AddModelError(nameof(mae.CPF), "CPF incorrecto");
             return(View(mae));
         }
     }
     return(View(mae));
 }