I need to direct the administrator to one location, the first-time student to another, and the student you have / p>
My validations are working, everything is working. However, I wonder if there is a best practice to apply for it:
[HttpPost]
public ActionResult Validar(String cpf, String senha)
{
var bdAluno = CONSUL_CA_AlunoAplicacaoConstrutor.CONSUL_CA_AlunoAplicacaoEF();
var alunos = bdAluno.ListarTodos().Where(x => x.Senha == senha);
if (alunos.Count() == 1)
{
var aluno = alunos.First();
if (aluno.Cpf == "1413914")
{
FormsAuthentication.SetAuthCookie("admin", false);
return RedirectToAction("Index", "HomeADM", new { area = "Administrador" });
}
else if (aluno.Senha == "sbe123") {
FormsAuthentication.SetAuthCookie(aluno.Cpf, false);
return RedirectToAction("AlterarSenha", "HomeAL", new { area = "Aluno" });
}
else {
FormsAuthentication.SetAuthCookie(aluno.Cpf, false);
return RedirectToAction("Index", "HomeAL", new { area = "Aluno" });
}
}
return RedirectToAction("Index");
}