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())); }
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()))); }
private Coupon GetCoupon(Guid?couponId) { return(couponId == null ? null : _couponsQuery.GetCoupon(couponId.Value)); }
public void TestCreateCoupon() { var coupon = CreateCoupon(0); _couponsCommand.CreateCoupon(coupon); AssertCoupon(coupon, _couponsQuery.GetCoupon(coupon.Id)); AssertCoupon(coupon, _couponsQuery.GetCoupon(coupon.Code)); }