コード例 #1
0
        public PriceList GetPrice(ICurrencyRateService rateService)
        {
            var list = new PriceList();

            foreach (var r in Rides)
            {
                var currencyRate = rateService.GetRate(CurrencyUnit.EUR, r.UnitPrice.CurrencyUnit, r.Start);
                var currencyItem = new CurrencyItem(CurrencyUnit.EUR, r.UnitPrice.CurrencyUnit, currencyRate);
                var distanceItem = new LogisticItem(r.Distance, r.DistanceUnit, Rounding.HalfToEven);

                var itemPrice = new ItemPrice(r.UnitPrice, distanceItem, currencyItem)
                {
                    Description = $"Ride from {r.From} to {r.To}."
                };
                list.Add(itemPrice);
            }

            var total = list.Sum();

            total.Description = $"Total.";
            list.Add(total);

            return(list);
        }