Beispiel #1
0
        public ActionResult CompletarCadastroVulneravel(int?id)
        {
            if (User.Identity.IsAuthenticated)
            {
                int      resId      = Convert.ToInt32(Request.Cookies.Get("userId").Value);
                Tutorias tut        = db.Tutorias.Find(id);
                Tutorias validation = db.Tutorias.Where(x => x.ResponsavelId == resId && x.PessoaId == tut.PessoaId).ToList().FirstOrDefault();
                if (validation == null)
                {
                    TempData["MSG"] = "warning|Não foi você quem cadastrou esse vulnerável";
                    return(RedirectToAction("Index", "Home"));
                }

                ConfirmaVulneravel cfm = new ConfirmaVulneravel();
                Pessoa             pes = db.Pessoa.Where(x => x.Id == tut.PessoaId).ToList().FirstOrDefault();
                if (pes != null)
                {
                    cfm.CpfVulneravel = pes.Cpf;
                    cfm.RgVulneravel  = pes.Rg;
                }
                cfm.codigo = tut.Id;

                return(View(cfm));
            }
            TempData["MSG"] = "warning|Logue antes de tentar alterar esse vulnerável";
            return(RedirectToAction("Index", "Home"));
        }
Beispiel #2
0
        public ActionResult CompletarCadastroVulneravel(ConfirmaVulneravel cfm)
        {
            Tutorias tut = db.Tutorias.Find(cfm.codigo);
            Pessoa   pes = db.Pessoa.Where(x => x.Id == tut.PessoaId).ToList().FirstOrDefault();

            pes.Cpf = cfm.CpfVulneravel;
            pes.Rg  = cfm.RgVulneravel;

            db.SaveChanges();

            return(RedirectToAction("DesaparecimentoVulneravel", "Vulneravels", new { id = tut.Id }));
        }