private string GetClientEmail(Order order) { var client = ClientRepository.Single(order.ClientID); return(client.Email); }
public void SendApproverEmail(int poid) { var order = OrderRepository.Single(poid); var acct = AccountRepository.Single(order.ClientID, order.AccountID); if (acct == null) { throw new Exception("The IOF must have an account before sending for approval."); } var client = ClientRepository.Single(order.ClientID); var approver = ClientRepository.GetApprover(order); StringBuilder sb = new StringBuilder(); sb.AppendLine("<div style=\"margin-top: 20px;\">"); sb.AppendLine($"<h3>Approver: {approver.DisplayName}</h3>"); sb.AppendLine("<hr/>"); string style1 = "text-align: right; padding: 6px 6px 6px 24px;"; string style2 = "padding: 6px 6px 6px 12px"; sb.AppendLine("<div style=\"padding: 10px;\">"); sb.AppendLine("<div style=\"padding-bottom: 10px;\"><b>IOF Info</b></div>"); sb.AppendLine("<table style=\"border-collapse: collapse;\">"); sb.AppendLine($"<tr><td style=\"{style1}\"><b>IOF #</b></td><td style=\"{style2}\">{order.POID}</td></tr>"); sb.AppendLine($"<tr><td style=\"{style1}\"><b>Vendor</b></td><td style=\"{style2}\">{order.VendorName}</td></tr>"); sb.AppendLine($"<tr><td style=\"{style1}\"><b>Account</b></td><td style=\"{style2}\">{acct.AccountDisplayName}</td></tr>"); sb.AppendLine($"<tr><td style=\"{style1}\"><b>Date Needed</b></td><td style=\"{style2}\">{order.NeededDate:M/d/yyyy}</td></tr>"); sb.AppendLine($"<tr><td style=\"{style1}\"><b>Notes</b></td><td style=\"{style2};\">{order.Notes}</td></tr>"); sb.AppendLine("</table>"); sb.AppendLine("</div>"); style1 = "border: solid 1px #444444; padding: 6px; background-color: #5078b3; color: #ffffff;"; sb.AppendLine("<hr/>"); sb.AppendLine("<div style=\"padding: 10px;\">"); sb.AppendLine("<div style=\"padding-bottom: 10px;\"><b>IOF Items</b></div>"); sb.AppendLine($"<table style=\"border-collapse: collapse; width: 100%;\">"); sb.AppendLine("<tr>"); sb.AppendLine($"<th style=\"{style1} width: 150px; text-align: left;\">Part #</th>"); sb.AppendLine($"<th style=\"{style1} text-align: left;\">Description</th>"); sb.AppendLine($"<th style=\"{style1} width: 150px; text-align: left;\">Category</th>"); sb.AppendLine($"<th style=\"{style1} width: 60px; text-align: right;\">Qty</th>"); sb.AppendLine($"<th style=\"{style1} width: 90px; text-align: right;\">Unit Price</th>"); sb.AppendLine($"<th style=\"{style1} width: 90px; text-align: right;\">Ext Price</th>"); sb.AppendLine("</tr>"); style1 = "border: solid 1px #808080; padding: 6px;"; double total = 0; foreach (var pod in DetailRepository.GetOrderDetails(order.POID)) { sb.AppendLine("<tr>"); sb.AppendLine($"<td style=\"{style1}\">{pod.PartNum}</td>"); sb.AppendLine($"<td style=\"{style1}\">{pod.Description}</td>"); sb.AppendLine($"<td style=\"{style1}\">{pod.CategoryNumber} - {pod.CategoryName}</td>"); sb.AppendLine($"<td style=\"{style1} text-align: right;\">{$"{pod.Quantity} {pod.Unit}".Trim()}</td>"); sb.AppendLine($"<td style=\"{style1} text-align: right;\">{pod.UnitPrice:C}</td>"); sb.AppendLine($"<td style=\"{style1} text-align: right;\">{pod.ExtPrice:C}</td>"); sb.AppendLine("</tr>"); total += pod.ExtPrice; } style1 = "border: solid 1px #808080; padding: 6px; background-color: #ccff99;"; sb.AppendLine("<tr>"); sb.AppendLine($"<td style=\"{style1}\"> </td>"); sb.AppendLine($"<td style=\"{style1}\"> </td>"); sb.AppendLine($"<td style=\"{style1}\"> </td>"); sb.AppendLine($"<td style=\"{style1}\"> </td>"); sb.AppendLine($"<td style=\"{style1} text-align: right;\"><b>Total:</b></td>"); sb.AppendLine($"<td style=\"{style1} text-align: right;\"><b>{total:C}</b></td>"); sb.AppendLine("</tr>"); sb.AppendLine("</table>"); sb.AppendLine("</div>"); sb.AppendLine("<hr/>"); sb.AppendLine("<div style=\"padding: 10px;\">"); sb.AppendLine("<div style=\"padding-bottom: 10px;\"><b>Attachments</b></div>"); var attachments = AttachmentService.GetAttachments(order.POID); if (attachments.Count() > 0) { sb.AppendLine("<ol>"); foreach (var a in attachments) { sb.AppendLine($"<li><a href=\"{a.Url}\">{a.FileName}</a></li>"); } sb.AppendLine("</ol>"); } else { sb.AppendLine("<div><i style=\"color: #808080;\">No attachments found.</i></div>"); } sb.AppendLine("</div>"); sb.AppendLine("<hr/>"); bool useApproveOrReject = GetUseApproveOrRejectSetting(); sb.AppendLine("<div style=\"padding: 10px;\">"); if (useApproveOrReject) { sb.AppendLine($"<div style=\"margin-bottom: 20px;\"><b><a href=\"{GetApproveOrRejectUrl(order)}\">Approve or Reject this IOF</a></b></div>"); } else { sb.AppendLine($"<div style=\"margin-bottom: 20px;\"><b><a href=\"{GetApproveUrl(order)}\">Approve this IOF</a></b></div>"); sb.AppendLine($"<div style=\"margin-bottom: 20px;\"><b><a href=\"{GetRejectUrl(order)}\">Reject this IOF</a></b></div>"); } sb.AppendLine("</div>"); sb.AppendLine("</div>"); var args = CreateArgs("IOF.Impl.EmailService.SendApproverEmail", $"IOF #{order.POID}: Request By {client.DisplayName}", sb.ToString(), approver.Email); Provider.Mail.SendMessage(args); }