public StatementData Create(Invoice invoice, List <Play> plays)
        {
            var result = new StatementData
            {
                Customer     = invoice.Customer,
                Performances = EnrichPerformance(invoice.Performances, plays)
            };

            result.TotalAumont        = CalculateTotalAumont(result);
            result.TotalVolumeCredits = CalculateTotalVolumeCredits(result);
            return(result);
        }
Пример #2
0
        public 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}: { Usd(perf.Aumont / 100)} ({ perf.Performance.Audience} seats)\n";
            }

            result += $"Amount owed is { Usd(data.TotalAumont / 100) }\n";
            result += $"You earned { data.TotalVolumeCredits } credits\n";
            return(result);
        }
Пример #3
0
        public string RenderHtml(StatementData data)
        {
            var result = $"<h1> Statement for { data.Customer }</h1>\n";

            result += "<table>\n";
            result += "<tr><th>play</th><th>seats</th><th>cost</th></tr>";
            foreach (var perf in data.Performances)
            {
                result += $"<tr><td>{ perf.Play.Name}</td><td>{ perf.Performance.Audience}</td>";
                result += $"<td>{ Usd(perf.Aumont)}</td></tr>\n";
            }
            result += "</table>\n";
            result += $"<p> Amount owed is <em> { Usd(data.TotalAumont)} </em></p>\n";
            result += $"<p> You earned <em> { data.TotalVolumeCredits} </em> credits </p>\n";
            return(result);
        }
 private decimal CalculateTotalAumont(StatementData data)
 {
     return(data.Performances.Sum(x => x.Aumont));
 }
 private decimal CalculateTotalVolumeCredits(StatementData data)
 {
     return(data.Performances.Sum(x => x.VolumeCredits));
 }