Example #1
0
        public double Handle(CalculateTrolleyQuery query)
        {
            TrolleyGuard.AgainstDuplicatePurchasedQuantities(query);

            var(appliedSpecials, remainingPurchasedQuantities) = SubstituteQuantitiesWithSpecials(query.Specials, query.Quantities);
            return(CalculateTotalPrice(query.Products, appliedSpecials, remainingPurchasedQuantities));
        }
Example #2
0
 public static void AgainstDuplicatePurchasedQuantities(CalculateTrolleyQuery query)
 {
     if (query.Quantities.GroupBy(quantity => quantity.Name).Any(grouping => grouping.Count() > 1))
     {
         throw new ArgumentException("Duplicate purchased product name not allowed");
     }
 }