コード例 #1
0
        public ActionResult Register(string email, string password, string phone, string address)
        {
            if (Session["UserId"] == null)
            {
                Session["UserId"] = _userSessionService.NewUser();
            }

            var response = new RegisterControllerIndexData
            {
                Basket = _userSessionService.GetBasketForUser(Session["UserId"].ToString()),
                Total  = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString())
            };

            var registerUserResponse = _userService.Register(email, password, phone, address);

            if (registerUserResponse.HasError)
            {
                response.HasError = true;
                response.Message  = registerUserResponse.Error.UserMessage;
                return(View("Index", response));
            }

            _userSessionService.LogIn(Session["UserId"].ToString(), registerUserResponse.UserId);
            return(Redirect("/"));
        }
コード例 #2
0
        public ActionResult Index()
        {
            if (Session["UserId"] == null)
            {
                Session["UserId"] = _userSessionService.NewUser();
            }

            if (_userSessionService.IsLoggedIn(Session["UserId"].ToString()))
            {
                return(Redirect("/"));
            }

            var response = new RegisterControllerIndexData
            {
                Basket   = _userSessionService.GetBasketForUser(Session["UserId"].ToString()),
                Total    = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString()),
                LoggedIn = _userSessionService.IsLoggedIn(Session["UserId"].ToString())
            };

            return(View(response));
        }