// GET: /Professor/Details/5
        public ActionResult Detalhes(int id = 0)
        {
            int LOTipoUsuario = (Int32)Session["tipoUsuario"];

            string LoginUsuario = (string)Session["LoginUsuario"];

            if (LOTipoUsuario == 5 || LOTipoUsuario == 3 || LOTipoUsuario == 4) //  3 4 -> professor, 5 -> adm
            {
                try
                {
                    Professor professor = new Professor();
                    if (id == 0)
                    {
                        professor = PRR.BuscarProfessorPorEmail(LoginUsuario);
                    }
                    else
                    {
                        professor = PRR.BuscarPorID(id);
                    }

                    if (professor.PRValido.Equals("N"))
                    {
                        ViewBag.Exception = "Seu Cadastro está inativo - Entre em contato com os administradores do sistema";
                        return(RedirectToAction("Entrar", "LoginUsuarios", new { erro = "Seu Cadastro está inativo - Entre em contato com os administradores do sistema" }));
                    }

                    return(View(professor));
                }

                catch (Exception e)
                {
                    ViewBag.Exception = e.ToString();
                }
            }
            return(View());
        }
コード例 #2
0
        public ActionResult Cadastrar(Projeto projeto)
        {
            int LOTipoUsuario = (Int32)Session["tipoUsuario"];

            if (LOTipoUsuario == 2 || LOTipoUsuario == 5) //   2 -> aluno lider , 5 -> adm
            {
                try
                {
                    int LOLogin = Int32.Parse((string)Session["LoginUsuario"]);

                    projeto.PRalunoLider = ALR.BuscarAlunoPorRA(LOLogin).ALIDaluno;

                    if (PR.BuscarAlunoLider(projeto.PRalunoLider) == null)
                    {
                        projeto.PRdescricao     = "Resposta1;Resposta2;Resposta3;Resposta4;Resposta5;Resposta6;Resposta7;Resposta8";
                        projeto.PRStatusProjeto = "A";
                        PR.Adicionar(projeto);

                        Professor prof = new Professor();
                        prof = PRR.BuscarPorID(projeto.PRorientador);

                        prof.PRtipoProfessor = 4;
                        PRR.Atualizar(prof);

                        PR.RelacionarAlunoLiderProjeto(projeto.PRIDprojeto, projeto.PRalunoLider);
                        PR.RelacionarOrientadorProjeto(projeto.PRIDprojeto, projeto.PRorientador);
                    }
                    else
                    {
                        ViewBag.PRorientador = new SelectList(PRR.BuscarTodosComCondicao(pr => pr.PRtipoProfessor == 3 || pr.PRtipoProfessor == 4), "PRIDprofessor", "PRNome");
                        ViewBag.Exception    = "O Aluno Lider já possui projeto ativo criado";
                        return(View(projeto));
                    }


                    return(RedirectToAction("Index"));
                }

                catch (Exception e)
                {
                    ViewBag.PRorientador = new SelectList(PRR.BuscarTodosComCondicao(pr => pr.PRtipoProfessor == 3 || pr.PRtipoProfessor == 4), "PRIDprofessor", "PRNome");
                    ViewBag.Exception    = e.ToString();
                    return(View(projeto));
                }
            }
            return(RedirectToAction("Entrar", "LoginUsuarios", new { erro = "Apenas Aluno Lider ou Administradores tem acesso a esse recurso" }));
        }