예제 #1
0
        public IHttpActionResult Post(SKUModel sku)
        {
            ApplyPromotion promotion = new ApplyPromotion();//Add unity for DI
            var            result    = promotion.GetCartPrice(sku);

            return(Ok(result));
        }
예제 #2
0
        public void Handle(ApplyPromotion command)
        {
            var promotion = _repository.Get(command.PromoId);

            promotion.Apply(command.OrderId, command.AccountId, command.PickupDate, command.IsFutureBooking);

            _repository.Save(promotion, command.Id.ToString());
        }
        private void ApplyPromotionIfNecessary(OrderCreated @event)
        {
            if (@event.PromotionId.HasValue)
            {
                var applyPromotionCommand = new ApplyPromotion
                {
                    PromoId         = @event.PromotionId.Value,
                    AccountId       = @event.AccountId,
                    OrderId         = @event.SourceId,
                    PickupDate      = @event.PickupDate,
                    IsFutureBooking = @event.IsFutureBooking
                };

                _commandBus.Send(applyPromotionCommand);
            }
        }
예제 #4
0
        public decimal CalculateCheckOutPrice()
        {
            decimal cartPrice  = 0;
            decimal finalPrice = 0;
            var     cartItems  = cart.GetAllCartItems();

            foreach (var item in cartItems)
            {
                cartPrice += (item.Price * item.Quantity);
            }
            finalPrice = cartPrice;

            if (!ApplyPromotion.CheckPromotionStatus(cart))
            {
                finalPrice = ApplyPromotion.ApplyPromotions(cart, promotions);
            }

            return(finalPrice);
        }