// GET: /Aluno/ public ActionResult Index() { if (Session["tipoUsuario"] == null) { return(RedirectToAction("Entrar", "LoginUsuarios", new { erro = "Faça seu login no sistema antes de acessar recursos" })); } try { int LOTipoUsuario = (Int32)Session["tipoUsuario"]; if (LOTipoUsuario == 5) // 5 -> adm { // aluno repositorio -> buscar AlunoPorLogin(usuario.LOLogin) var aluno = ALR.BuscarTodos(); return(View(aluno)); } if (LOTipoUsuario < 3) // 0 - 2 -> aluno { string LoginUsuario = (string)Session["LoginUsuario"]; return(RedirectToAction("Detalhes", "Aluno", new { id = ALR.BuscarAlunoPorRA(Int32.Parse(LoginUsuario)).ALIDaluno })); } } catch (Exception e) { ViewBag.Exception = e.ToString(); } return(View()); }
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" })); }