private HasNewsNotification BuildContractChangeNotification(List <ContractChange> changes, Customer customer) { StringBuilder header = _messageTemplateLogic.BuildHeader("Some items on your contract have changed", customer); MessageTemplateModel template = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_CONTRACTCHANGE); StringBuilder itemsContent = new StringBuilder(); foreach (ContractChange change in changes) { AddContractChangeToNotification(change, itemsContent); } HasNewsNotification notifcation = new HasNewsNotification() { CustomerNumber = changes[0].CustomerNumber, BranchId = changes[0].BranchId, Subject = template.Subject.Inject(new { CustomerNumber = customer.CustomerNumber, CustomerName = customer.CustomerName }), Notification = template.Body.Inject(new { NotifHeader = header.ToString(), ContractChangeItems = itemsContent.ToString() }) }; return(notifcation); }
private Message GetEmailMessageForNotification(SpecialOrderResponseModel specialorder, Customer customer) { Message message = new Message(); MessageTemplateModel template = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_SPECIALORDERCONFIRMATION); message.MessageSubject = template.Subject.Inject(new { OrderStatus = "SpecialOrder Confirmation", CustomerNumber = customer.CustomerNumber, CustomerName = customer.CustomerName }); StringBuilder header = _messageTemplateLogic.BuildHeader ("Your special order will arrive at the Ben E. Keith warehouse on the date below. " + "Your special order items will ship on your next order following the arrival date in our warehouse.", customer); message.MessageBody += template.Body.Inject(new { NotifHeader = header.ToString(), InvoiceNumber = specialorder.Item.InvoiceNumber, ShipDate = specialorder.Item.EstimatedArrival, Total = double.Parse(specialorder.Item.Price).ToString("f2"), ItemNumber = specialorder.Item.ItemNumber.ToString(), GTIN = specialorder.Item.GtinUpc, Source = specialorder.Header.ManufacturerName, Description = specialorder.Item.Description, Quantity = specialorder.Item.QuantityRequested }); message.BodyIsHtml = template.IsBodyHtml; message.CustomerNumber = customer.CustomerNumber; message.CustomerName = customer.CustomerName; message.BranchId = customer.CustomerBranch; message.NotificationType = NotificationType.OrderConfirmation; return(message); }
private Message MakeConfirmationMessage(OrderConfirmationNotification notification, Customer customer, StringBuilder originalOrderInfo, decimal totalAmount) { string invoiceNumber = GetInvoiceNumber(notification, customer); Message message = new Message(); MessageTemplateModel template = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_ORDERCONFIRMATION); message.MessageSubject = template.Subject.Inject(new { OrderStatus = "Order Confirmation", CustomerNumber = customer.CustomerNumber, CustomerName = customer.CustomerName, InvoiceNumber = invoiceNumber }); StringBuilder header = _messageTemplateLogic.BuildHeader("Thank you for your order", customer); message.MessageBody += template.Body.Inject(new { NotifHeader = header.ToString(), InvoiceNumber = invoiceNumber, ShipDate = notification.OrderChange.ShipDate, Count = notification.OrderChange.Items.Count, PcsCount = BuildPieceCount(notification), Total = totalAmount.ToString("f2"), PurchaseOrder = notification.OrderChange.OrderName, OrderConfirmationItems = originalOrderInfo.ToString() }); message.BodyIsHtml = template.IsBodyHtml; message.CustomerNumber = customer.CustomerNumber; message.CustomerName = customer.CustomerName; message.BranchId = customer.CustomerBranch; message.NotificationType = NotificationType.OrderConfirmation; //AlternateView avHtml = AlternateView.CreateAlternateViewFromString // (message.MessageBody, null, MediaTypeNames.Text.Html); //// Create a LinkedResource object for each embedded image //LinkedResource pic1 = new LinkedResource("pic.jpg", MediaTypeNames.Image.Jpeg); //pic1.ContentId = "Pic1"; //avHtml.LinkedResources.Add(pic1); return(message); }
private Message GetEmailMessageForNotification(List <PaymentTransactionModel> payments, Core.Models.Profile.Customer customer) { MessageTemplateModel template = _messageTemplateLogic.ReadForKey(Constants.MESSAGE_TEMPLATE_PAYMENTCONFIRMATION); MessageTemplateModel detailTemplate = _messageTemplateLogic.ReadForKey(Constants.MESSAGE_TEMPLATE_PAYMENTDETAIL); StringBuilder orderDetails = new StringBuilder(); foreach (var payment in payments) { var invoice = _invoiceRepo.GetInvoiceHeader(DivisionHelper.GetDivisionFromBranchId(customer.CustomerBranch), customer.CustomerNumber, payment.InvoiceNumber); var invoiceTyped = KeithLink.Svc.Core.Extensions.InvoiceExtensions.DetermineType(invoice.InvoiceType); orderDetails.Append(detailTemplate.Body.Inject(new { InvoiceType = invoiceTyped, InvoiceNumber = payment.InvoiceNumber, InvoiceDate = invoice.InvoiceDate, DueDate = invoice.DueDate, ScheduledDate = payment.PaymentDate, PaymentAmount = payment.PaymentAmount })); } var bank = _bankRepo.GetBankAccount(DivisionHelper.GetDivisionFromBranchId(customer.CustomerBranch), customer.CustomerNumber, payments[0].AccountNumber); var confirmationId = payments[0].ConfirmationId; Message message = new Message(); message.BodyIsHtml = template.IsBodyHtml; message.MessageSubject = template.Subject.Inject(customer); StringBuilder header = _messageTemplateLogic.BuildHeader("Thank you for your payment", customer); message.MessageBody = template.Body.Inject(new { NotifHeader = header.ToString(), ConfirmationId = confirmationId, BankAccount = string.Format("{0} - {1}", GetBankAccountNumber(bank), GetBankName(bank)), PaymentDetailLines = orderDetails.ToString(), TotalPayments = payments.Sum(p => p.PaymentAmount) }); message.CustomerNumber = customer.CustomerNumber; message.CustomerName = customer.CustomerName; message.BranchId = customer.CustomerBranch; message.NotificationType = NotificationType.PaymentConfirmation; return(message); }
/// <summary> /// Creates email message from user feeedback notification. /// </summary> /// <param name="notification"></param> /// <returns></returns> private Message CreateEmailMessageForNotification(UserFeedbackNotification notification) { Message message = new Message(); MessageTemplateModel template = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_USERFEEDBACK); var context = notification.Context; var userFeedback = notification.UserFeedback; message.MessageSubject = template.Subject.Inject(new { CustomerNumber = context.CustomerNumber, CustomerName = context.CustomerName, Audience = userFeedback.Audience.ToString(), }); Customer customer = _customerRepository.GetCustomerByCustomerNumber(notification.CustomerNumber, notification.BranchId); StringBuilder header = _messageTemplateLogic.BuildHeader("Feedback from ", customer); message.MessageBody += template.Body.Inject(new { NotifHeader = header.ToString(), UserFirstName = context.UserFirstName, UserLastName = context.UserLastName, SourceEmailAddress = context.SourceEmailAddress, SalesRepName = context.SalesRepName, Subject = userFeedback.Subject, Content = userFeedback.Content, }); message.BodyIsHtml = template.IsBodyHtml; message.CustomerNumber = context.CustomerNumber; message.CustomerName = context.CustomerName; message.BranchId = context.BranchId; message.NotificationType = NotificationType.UserFeedback; return(message); }