public ActionResult Index(user user) { bool authenticated = loginBL.IsAuthenticated(user); if (authenticated) { Session["authenticated"] = true; // present user full name in nav-bar string userFullName = loginBL.GetUserFullName(user.UserName); Session["userFullName"] = userFullName; // all controllers will check action for selected uesr Session["userName"] = user.UserName; //update dataBase for currentUser loginBL.UpdateActions(user.UserName); // present user actions in nav-bar var selectedUser = loginBL.GetUser(user.UserName); Session["AmountOfActions"] = selectedUser.ActionsCounter; // user used all of his actions if (loginBL.GetUpdateActionsForUser(user.UserName) < 0) { Session.Clear(); TempData["ErrorMessage"] = "Logout by the system! user doesn't have actions"; return(RedirectToAction("Index")); } else { return(View("HomePage")); } } else { Session["authenticated"] = false; TempData["ErrorMessage"] = "Login Failed! Such a user doesn't exist on the site"; return(RedirectToAction("Index")); } }