Exemplo n.º 1
0
        public decimal GetTotalPrice(List <ILiterature> literature, bool isDelivery, List <IPromo> promoCodes)
        {
            var order = new Order(literature)
            {
                DeliveryPrice = isDelivery ? _deliveryCalculator.GetDeliveryPrice(literature) : 0
            };

            promoCodes.ForEach(p => p.ApplyPromo(order));
            _actionProvider.GetActiveActions().ForEach(a => a.ApplyAction(order, _shopLibrary.libraryList));

            return(order.GetTotalFinalPrice());
        }
Exemplo n.º 2
0
        public decimal GetTotalPrice(List <IProduct> products, bool isDelivery, List <IPromo> promoCodes)
        {
            var order = new Order(products)
            {
                DeliveryPrice = isDelivery ? _deliveryCalculator.GetDeliveryPrice(products) : 0
            };

            promoCodes.ForEach(p => p.ApplyPromo(order));
            _actionProvider.GetActiveActions().ForEach(a => a.ApplyAction(order));

            return(order.GetTotalFinalPrice());
        }
Exemplo n.º 3
0
        public decimal GetTotalPrice(List <IProduct> items, List <IPromo> promoCodes)
        {
            var  order      = new Order(items);
            bool isDelivery = order.OrderItems
                              .Where(item => item.Item.IsDelivery == true)
                              .Count() != 0;

            order.DeliveryPrice = isDelivery ? _deliveryCalculator.GetDeliveryPrice(items) : 0;

            promoCodes.ForEach(p => p.ApplyPromo(order));
            _actionProvider.GetActiveActions().ForEach(a => a.ApplyAction(order));

            return(order.GetTotalFinalPrice());
        }
Exemplo n.º 4
0
        public double CalcPayment()
        {
            foreach (var promo in this.ListPromo)
            {
                promo.ApplyPromo(this.Order);
            }

            actionProvider.GetActiveActions().ForEach(a => a.ApplyAction(this.Order));

            double result = this.Order.TotalCost;

            Console.WriteLine($"Цена { Order.Cost}");
            Console.WriteLine($"Доставка { Order.Delivery}");
            Console.WriteLine($"Скидка { Order.Discount}");
            Console.WriteLine($"Итого { result}");

            return(result);
        }