public ActionResult CheckLogin(string usrname, string pswrd) { if (Session["user"] != null) { UserLogined user = (UserLogined)Session["user"]; var datetime = DateTime.Now; var date = datetime.Date; var userlogindatetime = user.LoginDate; var userlogindate = userlogindatetime.Date; if (date != userlogindate) { user.LoginDate = DateTime.Now; var userBL = usersBL.AuthorizeUser(usrname, pswrd); user.NumOfActions = userBL.NumOfActions; Session["user"] = user; } if (user.Logined == true && user.NumOfActions != 0) { return(View("HomePage")); } else { TempData["Message"] = "You Have no action left for today, pls come back tomorrow"; return(RedirectToAction("Index")); } } else { var userBL = usersBL.AuthorizeUser(usrname, pswrd); if (userBL != null) { UserLogined user = new UserLogined(); user.FullName = userBL.FullName; user.UserName = userBL.UserName; user.Logined = true; user.LoginDate = DateTime.Now; user.NumOfActions = userBL.NumOfActions; Session["user"] = user; Session["username"] = user.FullName; return(RedirectToAction("HomePage")); } else { TempData["Message"] = "You Are not authorized!"; return(RedirectToAction("Index")); } } }