private StatementData GenerateStatementData(Invoice invoice)
        {
            var performancesData = EnrichPerformances(invoice);
            var statementData    = new StatementData(invoice.Customer,
                                                     performancesData,
                                                     TotalAmount(performancesData),
                                                     TotalVolumeCredits(performancesData));

            return(statementData);
        }
예제 #2
0
        private string RenderPlainText(StatementData data)
        {
            var result = $"Statement for {data.Customer}\n";

            foreach (var perf in data.Performances)
            {
                // print line for this order
                result += $"  {perf.Play.Name}: {FormatUtilities.Usd(perf.Amount)} ({perf.Audience} seats)\n";
            }

            result += $"Amount owed is {FormatUtilities.Usd(data.TotalAmount)}\n";
            result += $"You earned {data.TotalVolumeCredits} credits\n";
            return(result);
        }
예제 #3
0
        private string RenderHtml(StatementData data)
        {
            var result = $"<h1>{data.Customer}</h1>\n";

            result += "<table>\n";
            result += "<tr><th>play</th><th>seats</th><th>cost</th>\n";
            foreach (var perf in data.Performances)
            {
                // print line for this order
                result += $"<tr><td>{perf.Play.Name}</td><td>{perf.Audience}</td><td>{FormatUtilities.Usd(perf.Amount)}</td>\n";
            }

            result += "</table>\n";
            result += $"<p>Amount owed is <em>{FormatUtilities.Usd(data.TotalAmount)}</em></p>\n";
            result += $"<p>You earned <em>{data.TotalVolumeCredits}</em> credits</p>\n";
            return(result);
        }