Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public ActionResult ApplyDeal(int dealId)
        {
            var getVoucherById = _voucherService.GetById(dealId);

            if (getVoucherById.HasError)
            {
                return(Redirect("/Deals"));
            }

            _userSessionService.SelectDeal(Session["UserId"].ToString(), VoucherDetailsMapper.Map(
                                               new List <VoucherDetails>
            {
                new VoucherDetails
                {
                    Voucher = getVoucherById.Voucher,
                    AllowedDeliveryTypes = getVoucherById.AllowedDeliveryTypes,
                    AllowedSizes         = getVoucherById.AllowedSizes
                }
            })[0]);
            return(Redirect("/Deals"));
        }
Exemplo n.º 3
0
        public IHttpActionResult ApplyDeal([FromBody] ApplyDealRequest request)
        {
            var getVoucherById = _voucherService.GetById(request.DealId);

            if (getVoucherById.HasError)
            {
                return(BadRequest());
            }

            _userSessionService.SelectDeal(request.UserToken, VoucherDetailsMapper.Map(
                                               new List <VoucherDetails>
            {
                new VoucherDetails
                {
                    Voucher = getVoucherById.Voucher,
                    AllowedDeliveryTypes = getVoucherById.AllowedDeliveryTypes,
                    AllowedSizes         = getVoucherById.AllowedSizes
                }
            })[0]);

            return(Ok(_userSessionService.GetVoucherForUser(request.UserToken)));
        }
Exemplo n.º 4
0
 public IHttpActionResult GetAll()
 {
     return(Ok(VoucherDetailsMapper.Map(_voucherService.GetAll().VoucherDetails)));
 }