Пример #1
0
        public string GetCoffeesSummary()
        {
            var lines = OfferedCoffees
                        .OrderBy(x => (string)x.Key)
                        .Select(x => $"{x.Key}: {x.Value.Name} ({x.Value.Price} per {x.Value.NetWeightPerBag} bag) - {x.Value.Description}");

            var sb = new StringBuilder();

            foreach (var line in lines)
            {
                sb.AppendLine(line);
            }

            return(sb.ToString());
        }
Пример #2
0
        public void AddCoffee(OrderReferenceLabel label, Coffee coffee)
        {
            if (OfferedCoffees.ContainsKey(label))
            {
                throw new CoffeeLabelAlreadyUsedInRoastingEventException(label);
            }

            if (OfferedCoffees.Values.Contains(coffee))
            {
                throw new CoffeeAlreadyAddedToRoastingEventException(coffee);
            }

            var updatedCoffees = OfferedCoffees.ToDictionary(x => x.Key, x => x.Value);

            updatedCoffees.Add(label, coffee);

            OfferedCoffees = new ReadOnlyDictionary <OrderReferenceLabel, Coffee>(updatedCoffees);
        }