public ActionResult Index()
        {
            if (Session["UserId"] == null)
            {
                Session["UserId"] = _userSessionService.NewUser();
            }

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

            return(View(response));
        }
Esempio n. 2
0
        public IHttpActionResult GetBasketTotal()
        {
            if (Request.Headers.Authorization == null)
            {
                return(Unauthorized());
            }

            return(Ok(_userSessionService.GetBasketTotalForUser(Encoding.UTF8.GetString(Convert.FromBase64String(Request.Headers.Authorization.Parameter)))));
        }
Esempio n. 3
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));
        }
        public ActionResult Index()
        {
            if (Session["UserId"] == null)
            {
                Session["UserId"] = _userSessionService.NewUser();
            }

            var response = new DealControllerIndexData
            {
                VoucherDetails = _userSessionService.GetVoucherForUser(Session["UserId"].ToString()),
                Vouchers       = VoucherDetailsMapper.Map(_voucherService.GetAll().VoucherDetails),
                Total          = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString()),
                LoggedIn       = _userSessionService.IsLoggedIn(Session["UserId"].ToString())
            };

            return(View(response));
        }
Esempio n. 5
0
        public ActionResult Index()
        {
            var response = new HomeControllerIndexData
            {
                Pizzas = _pizzaSizeService.GetAll().Pizzas,
                Form   = new FormModel
                {
                    ExtraToppings = _toppingService.GetAll().Toppings.ToDictionary(x => x, y => false),
                    Sizes         = _sizeService.GetAll().Sizes.ToDictionary(x => x, y => false)
                }
            };

            if (Session["UserId"] == null)
            {
                Session["UserId"] = _userSessionService.NewUser();
            }
            else
            {
                response.Total    = _userSessionService.GetBasketTotalForUser(Session["UserId"].ToString());
                response.LoggedIn = _userSessionService.IsLoggedIn(Session["UserId"].ToString());
            }

            return(View(response));
        }