Example #1
0
        public ActionResult Coupon(string code, Guid[] productIds)
        {
            try
            {
                if (string.IsNullOrEmpty(code))
                {
                    throw new CouponNotFoundException();
                }

                var coupon = _couponsQuery.GetCoupon(code);
                if (coupon == null)
                {
                    throw new CouponNotFoundException();
                }

                var user = CurrentRegisteredUser;
                _ordersCommand.ValidateCoupon(coupon, user == null ? (Guid?)null : user.Id, productIds);

                return(Json(new JsonCouponModel {
                    Id = coupon.Id, Code = coupon.Code
                }));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }
Example #2
0
        public ActionResult PrepareOrder(Guid[] productIds, CheckBoxValue useDiscount, Guid?couponId, CreditCardType?creditCardType)
        {
            var coupon = couponId == null ? null : _couponsQuery.GetCoupon(couponId.Value);
            var order  = GetOrder(productIds, useDiscount, coupon, creditCardType);

            return(PartialView("OrderDetails", _employerOrdersQuery.GetOrderDetails(_creditsQuery, order, _productsQuery.GetProducts())));
        }
Example #3
0
 private Coupon GetCoupon(Guid?couponId)
 {
     return(couponId == null
         ? null
         : _couponsQuery.GetCoupon(couponId.Value));
 }
Example #4
0
        public void TestCreateCoupon()
        {
            var coupon = CreateCoupon(0);

            _couponsCommand.CreateCoupon(coupon);
            AssertCoupon(coupon, _couponsQuery.GetCoupon(coupon.Id));
            AssertCoupon(coupon, _couponsQuery.GetCoupon(coupon.Code));
        }