示例#1
0
        public string GetOrderSummary()
        {
            var cart    = new Cart(CartLines);
            var summary = new StringBuilder("Nowe zamówienie").AppendLine(SummaryDelimiter).AppendLine("Produkty: ");

            cart.Items.ToList().ForEach(
                line => summary.AppendLine(
                    $"{line.Quantity} x {line.Product.Price} (wartość: {line.GetSubtotal():C})"));

            summary.AppendLine($"Wartość całkowita: {cart.ComputeTotal():C}")
            .AppendLine(SummaryDelimiter)
            .AppendLine("Wysyłka dla: ")
            .AppendLine(ClientName)
            .AppendLine(Address.Line1)
            .AppendLine(Address.Line2 ?? string.Empty)
            .AppendLine(Address.Line3 ?? string.Empty)
            .AppendLine(Address.City)
            .AppendLine(Address.State)
            .AppendLine(Address.Country)
            .AppendLine(Address.Zip)
            .AppendLine(SummaryDelimiter)
            .AppendLine($"Pakowanie prezentów: {(GiftWrap ? "Tak" : "Nie")}");

            return(summary.ToString());
        }