| | | 1 | | using System.Text; |
| | | 2 | | |
| | | 3 | | namespace Services.Builders; |
| | | 4 | | |
| | | 5 | | public class OrderSummaryTableBuilder |
| | | 6 | | { |
| | | 7 | | private readonly StringBuilder _builder; |
| | | 8 | | |
| | 0 | 9 | | public OrderSummaryTableBuilder() |
| | | 10 | | { |
| | 0 | 11 | | _builder = new StringBuilder(); |
| | 0 | 12 | | _builder.AppendLine("<table class=\"table table-bordered table-striped table-sm\">"); |
| | 0 | 13 | | _builder.AppendLine("<thead><tr>"); |
| | 0 | 14 | | _builder.AppendLine("<th>Shipment №</th>"); |
| | 0 | 15 | | _builder.AppendLine("<th>Статус</th>"); |
| | 0 | 16 | | _builder.AppendLine("<th>Описание</th>"); |
| | 0 | 17 | | _builder.AppendLine("<th>Дата</th>"); |
| | 0 | 18 | | _builder.AppendLine("</tr></thead>"); |
| | 0 | 19 | | _builder.AppendLine("<tbody>"); |
| | 0 | 20 | | } |
| | | 21 | | |
| | | 22 | | public void AddRow(string shipmentNumber, bool isSuccess, string description) |
| | | 23 | | { |
| | 0 | 24 | | var status = isSuccess ? "✅ Успешно" : "❌ Ошибка"; |
| | 0 | 25 | | var time = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss"); |
| | | 26 | | |
| | 0 | 27 | | _builder.AppendLine("<tr>"); |
| | 0 | 28 | | _builder.AppendLine($"<td>{shipmentNumber}</td>"); |
| | 0 | 29 | | _builder.AppendLine($"<td>{status}</td>"); |
| | 0 | 30 | | _builder.AppendLine($"<td>{description}</td>"); |
| | 0 | 31 | | _builder.AppendLine($"<td>{time}</td>"); |
| | 0 | 32 | | _builder.AppendLine("</tr>"); |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | public string Build() |
| | | 36 | | { |
| | 0 | 37 | | _builder.AppendLine("</tbody></table>"); |
| | 0 | 38 | | return _builder.ToString(); |
| | | 39 | | } |
| | | 40 | | } |