/// <summary> /// Builds a plain text formatted receipt string /// </summary> /// <returns>A plain text Receipt string</returns> public string PrintReceipt() { ReceiptResult.Append(string.Format("Order Receipt for {0}{1}", Order.Company, Environment.NewLine)); PrintLines(); ReceiptResult.AppendLine(string.Format("Sub-Total: {0}", TotalAmount.ToString("C"))); ReceiptResult.AppendLine(string.Format("Tax: {0}", CalculateTax().ToString("C"))); ReceiptResult.Append(string.Format("Total: {0}", TotalAmount.ToString("C"))); return(ReceiptResult.ToString()); }
/// <summary> /// Builds and returns an HTML formated receipt /// </summary> /// <returns>An HTML formatted receipt</returns> public string PrintReceipt() { ReceiptResult.Append(string.Format("<html><body><h1>Order Receipt for {0}</h1>", Order.Company)); PrintLines(); ReceiptResult.Append(string.Format("<h3>Sub-Total: {0}</h3>", TotalAmount.ToString("C"))); ReceiptResult.Append(string.Format("<h3>Tax: {0}</h3>", CalculateTax().ToString("C"))); ReceiptResult.Append(string.Format("<h2>Total: {0}</h2>", TotalAmount.ToString("C"))); ReceiptResult.Append("</body></html>"); return(ReceiptResult.ToString()); }
/// <summary> /// Processes each line item if any for an order and appends to the string builder object /// </summary> private void PrintLines() { if (Order.Lines.Any()) { ReceiptResult.Append("<ul>"); foreach (var line in Order.Lines) { ReceiptResult.Append(string.Format("<li>{0} x {1} {2} = {3}</li>", line.Quantity, line.Bike.Brand, line.Bike.Model, CalculateLineTotals(line).ToString("C"))); } ReceiptResult.Append("</ul>"); } }