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)); }
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")); }
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))); }
public IHttpActionResult GetAll() { return(Ok(VoucherDetailsMapper.Map(_voucherService.GetAll().VoucherDetails))); }