1
In my project I came up with this business rule.
I need to pick up the last time the user logged in to the system. So it would be something so that I could catch the day and time of the last login.
I already have the column created in the database called UltimoLogin
which is a DateTime
.
Can someone help me?
Code of Controller
Autenticacaocontroller
[HttpPost]
public ActionResult Index(String Login, String Senha)
{
//verificando login pelo usuario do banco de dados ...
Usuario login = db.Usuarios.Where(x => x.Login == Login && x.Senha == Senha).FirstOrDefault();
if (login != null)
{
FormsAuthentication.SetAuthCookie(login.Nome.ToString(), false);
Session.Add(".PermissionCookie", login.Perfil);
Session.Add("UsuarioID", login.UsuarioID);
return RedirectToAction("Index", "Home"); // página padrão para todos os usuários
}
return RedirectToAction("Index");
}