Beispiel #1
0
        public string Print()
        {
            StringBuilder builder  = new StringBuilder();
            var           products = ProductQuantities.GroupBy(p => p.Key.Category.Title).ToDictionary(e => e.Key, e => e.ToList());

            builder.AppendLine($"{"Category Name",15}  {"Product Name",15}  {"Quantity",15}  {"Unit Price",15}  {"Total Price",15}");
            foreach (var item in products)
            {
                foreach (var p in item.Value)
                {
                    builder.AppendLine($"{item.Key,15} {p.Key.Title,15} {p.Value,15} {p.Key.Price,15} {GetProductPrice(p.Key),15}\t");
                }
            }
            builder.AppendLine($"\nTotal Amount: {GetTotalAmount()}\nTotal Amount After Discounts: {GetTotalAmountAfterDiscounts()}" +
                               $"\nTotal Discount: {GetTotalAmount() - GetTotalAmountAfterDiscounts()}\nDelivery Cost: {GetDeliveryCost()}");
            return(builder.ToString());
        }
Beispiel #2
0
 public int GetNumberOfDeliveries()
 {
     return(ProductQuantities.GroupBy(e => e.Key.Category.Title).Count());
 }