public ActionResult Login(string email, string password) { var userServiceResponse = _userService.Login(email, password); var response = new LoginControllerIndexData { Basket = _userSessionService.GetBasketForUser(Session["UserId"].ToString()), Total = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString()), LoggedIn = _userSessionService.IsLoggedIn(Session["UserId"].ToString()) }; if (userServiceResponse.HasError) { response.HasError = true; response.Message = userServiceResponse.Error.UserMessage; return(View("Index", response)); } _userSessionService.LogIn(Session["UserId"].ToString(), userServiceResponse.UserId); return(Redirect("Index")); }
public ActionResult Index() { if (Session["UserId"] == null) { Session["UserId"] = _userSessionService.NewUser(); } if (_userSessionService.IsLoggedIn(Session["UserId"].ToString())) { return(Redirect("/")); } var response = new LoginControllerIndexData { Basket = _userSessionService.GetBasketForUser(Session["UserId"].ToString()), Total = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString()), LoggedIn = _userSessionService.IsLoggedIn(Session["UserId"].ToString()) }; return(View(response)); }