[TestFixtureSetUp] public void Context()
 {
     _order = CreateOrder.Of(new Product(10)
     {
         IsLuxuryItem = true
     }).Apply(CreatePromotion.WithDiscountOf(.1m)).In(StateOf.NV);
 }
        [TestFixtureSetUp] public void Context()
        {
            Product   product   = new Product(10);
            Promotion promotion = CreatePromotion.WithDiscountOf(.1m).Starting(DateTime.Now.AddDays(-4)).Ending(DateTime.Now.AddDays(-1));

            _order = CreateOrder.Of(product).On(DateTime.Now).Apply(promotion).In(StateOf.UT);
        }
        [TestFixtureSetUp] public void Context()
        {
            Product   product   = new Product(5);
            Promotion promotion = CreatePromotion.WithDiscountOf(.1m);
            Coupon    coupon    = CreateCoupon.For(product).WithDiscountOf(.2m);

            _order = CreateOrder.Of(product, product).Apply(promotion, coupon).In(StateOf.UT);
        }
示例#4
0
        private static void Sample5()
        {
            Product luxuryProduct = new Product(10)
            {
                IsLuxuryItem = true
            };
            Product nonLuxuryProduct = new Product(10);
            Order   order            = CreateOrder.Of(luxuryProduct, nonLuxuryProduct).
                                       Apply(CreatePromotion.WithDiscountOf(.1m), CreateCoupon.For(luxuryProduct).WithDiscountOf(.5m)).
                                       In(StateOf.NC);

            DisplayOrder(order, "Order in North Carolina (5% tax rate) with $10 luxury item and $10 non-luxury item and 10% promotion and 50% coupon on luxury item:");
        }
示例#5
0
 [TestFixtureSetUp] public void Context()
 {
     _order = CreateOrder.Of(new Product(10)).Apply(CreatePromotion.WithDiscountOf(.5m)).In(StateOf.FL);
 }
        public ActionResult Create(PromoCodeModel promoCode)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var validationErrors = string.Join(", ",
                                                       ModelState.Values.Where(x => x.Errors.Count > 0)
                                                       .SelectMany(x => x.Errors)
                                                       .Select(x => x.ErrorMessage)
                                                       .ToArray());
                    throw new Exception(string.Format("Something's not right.{0}{1}", Environment.NewLine, validationErrors));
                }

                if (_promotionDao.FindByPromoCode(promoCode.Code) != null)
                {
                    throw new Exception("A promotion with this code already exists");
                }

                var promotionId = Guid.NewGuid();
                promoCode.Id = promotionId;

                var createPromotionCommand = new CreatePromotion
                {
                    PromoId                 = promotionId,
                    Name                    = promoCode.Name,
                    Description             = promoCode.Description,
                    StartDate               = promoCode.StartDate,
                    EndDate                 = promoCode.EndDate,
                    DaysOfWeek              = promoCode.DaysOfWeek,
                    StartTime               = promoCode.StartTime,
                    EndTime                 = promoCode.EndTime,
                    AppliesToCurrentBooking = promoCode.AppliesToCurrentBooking,
                    AppliesToFutureBooking  = promoCode.AppliesToFutureBooking,
                    DiscountValue           = promoCode.DiscountValue,
                    DiscountType            = promoCode.DiscountType,
                    Code                    = promoCode.Code,
                    TriggerSettings         = promoCode.TriggerSettings
                };

                if (promoCode.TriggerSettings.Type == PromotionTriggerTypes.NoTrigger)
                {
                    createPromotionCommand.PublishedStartDate = promoCode.PublishedStartDate;
                    createPromotionCommand.PublishedEndDate   = promoCode.PublishedEndDate;
                }
                else
                {
                    // Trigger promotions are always published (but user will only see them when whitelisted)
                    createPromotionCommand.PublishedStartDate = SqlDateTime.MinValue.Value;
                    createPromotionCommand.PublishedEndDate   = SqlDateTime.MaxValue.Value;
                }

                if (promoCode.TriggerSettings.Type != PromotionTriggerTypes.CustomerSupport)
                {
                    // User and system usage is unlimited for support promotion. The whitelist will determine if a user can use it.
                    createPromotionCommand.MaxUsage        = promoCode.MaxUsage;
                    createPromotionCommand.MaxUsagePerUser = promoCode.MaxUsagePerUser;
                }

                _commandBus.Send(createPromotionCommand);

                TempData["Info"] = string.Format("Promotion \"{0}\" created", promoCode.Name);

                var promotions = _promotionDao.GetAll().Select(x => new PromoCodeModel(x)).ToList();
                promotions.Add(promoCode);
                var orderedPromotions = promotions.OrderBy(p => p.Name);

                TempData["Model"] = orderedPromotions;

                return(RedirectToAction("Index", orderedPromotions));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View(promoCode));
            }
        }
示例#7
0
        private static void Sample1()
        {
            Product luxuryProduct = new Product(10)
            {
                IsLuxuryItem = true
            };
            Product nonLuxuryProduct = new Product(10);
            Order   order            = CreateOrder.Of(luxuryProduct, nonLuxuryProduct).Apply(CreatePromotion.WithDiscountOf(.1m)).In(StateOf.FL);

            DisplayOrder(order, "Order in Florida (5% tax rate) with $10 luxury item and $10 non-luxury item and 10% promotion:");
        }
示例#8
0
 [TestFixtureSetUp] public void Context()
 {
     _order = CreateOrder.Of().Apply(CreatePromotion.WithDiscountOf(.1m)).In(StateOf.AR);
 }