示例#1
0
        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);
        }
示例#2
0
        public bool ForwardUserMessage(UserProfile requester, ForwardUserMessageModel forwardrequest)
        {
            UserMessage          userMessage     = _userMessageRepository.ReadById(forwardrequest.Id);
            MessageTemplateModel forwardTemplate =
                _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_FORWARDUSERMESSAGE);

            try
            {
                string body = forwardTemplate.Body.Inject
                                  (new {
                    UserEmail   = requester.EmailAddress,
                    ForwardBody = userMessage.Body
                });

                _emailClient.SendEmail
                    (new List <string>()
                {
                    forwardrequest.EmailAddress
                },
                    null,
                    null,
                    userMessage.Subject,
                    body,
                    true);
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("ForwardUserMessage: Error sending email", ex);
            }

            return(true);
        }
        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);
        }
示例#4
0
        protected Message GetEmailMessageForNotification(IEnumerable <OrderEta> orderEtas, IEnumerable <OrderHistoryHeader> orders, Svc.Core.Models.Profile.Customer customer)
        {
            // TODO: Add logic for delivered orders (actualtime) - not needed now, but maybe in the future.
            StringBuilder        orderInfoDetails     = new StringBuilder();
            MessageTemplateModel orderEtaLineTemplate = messageTemplateLogic.ReadForKey("OrderEtaLine");
            string timeZoneName = string.Empty;

            foreach (var o in orders)
            {
                OrderEta eta = orderEtas.Where(ordereta => ordereta.OrderId == o.InvoiceNumber).FirstOrDefault();
                DateTime?estimatedDelivery = DateTime.Parse(eta.EstimatedTime).ToCentralTime();  // will parse into local time, then convert to central
                DateTime?scheduledDelivery = DateTime.Parse(eta.ScheduledTime).ToCentralTime();
                DateTime?actualDelivery    = DateTime.Parse(eta.ActualTime).ToCentralTime();
                object   orderLineDetails  =
                    new {
                    InvoiceNumber         = o.InvoiceNumber,
                    ProductCount          = o.OrderDetails.Count.ToString(),
                    ShippedQuantity       = o.OrderDetails.Sum(od => od.ShippedQuantity).ToString(),
                    ScheduledDeliveryDate = scheduledDelivery.Value.ToShortDateString(),
                    ScheduledDeliveryTime = scheduledDelivery.Value.ToShortTimeString(),
                    EstimatedDeliveryDate = estimatedDelivery.Value.ToShortDateString(),
                    EstimatedDeliveryTime = estimatedDelivery.Value.ToShortTimeString()
                };
                orderInfoDetails.Append(orderEtaLineTemplate.Body.Inject(orderLineDetails));

                if (timeZoneName == string.Empty)
                {
                    TimeZoneInfo centralTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
                    timeZoneName = (centralTimeZone.IsDaylightSavingTime(scheduledDelivery.Value) ? centralTimeZone.DaylightName : centralTimeZone.StandardName);
                }
            }

            MessageTemplateModel orderEtaMainTemplate = messageTemplateLogic.ReadForKey("OrderEtaMain");

            Message message = new Message();

            //message.MessageSubject = orderEtaMainTemplate.Subject.Inject(new { CustomerName = string.Format("{0-{1}", customer.CustomerNumber, customer.CustomerName) });
            message.MessageSubject   = orderEtaMainTemplate.Subject.Inject(customer);
            message.MessageBody      = orderEtaMainTemplate.Body.Inject(new { TimeZoneName = timeZoneName, EtaOrderLines = orderInfoDetails.ToString() });
            message.CustomerNumber   = customer.CustomerNumber;
            message.CustomerName     = customer.CustomerName;
            message.BranchId         = customer.CustomerBranch;
            message.NotificationType = NotificationType.OrderConfirmation;
            return(message);
        }
        private void BuildExceptionItemDetail(StringBuilder itemOrderInfoOOS, OrderLineChange line, string priceInfo, string extPriceInfo, Product currentProduct)
        {
            MessageTemplateModel itemOOSDetailTemplate = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_ORDERITEMOOSDETAIL);
            StringBuilder        number = new StringBuilder();

            number.Append(line.ItemNumber);
            if (line.SubstitutedItemNumber != null && line.SubstitutedItemNumber.Trim().Length > 0)
            {
                number.Append(" to " + line.SubstitutedItemNumber);
            }
            StringBuilder status = new StringBuilder();

            status.Append(line.OriginalStatus);
            if (line.NewStatus != null && line.NewStatus.Trim().Length > 0)
            {
                status.Append(" to " + line.NewStatus);
            }

            object lineData = null;

            if (currentProduct == null)
            {
                lineData = new {
                    ProductNumber      = number.ToString(),
                    ProductDescription = "Unknown",
                    Brand    = "Unknown",
                    Quantity = line.QuantityOrdered.ToString(),
                    Sent     = line.QuantityShipped.ToString(),
                    Pack     = "Unknown",
                    Size     = "Unknown",
                    Price    = priceInfo,
                    Status   = status.ToString()
                };
            }
            else
            {
                lineData = new {
                    ProductNumber      = number.ToString(),
                    ProductDescription = currentProduct.Name,
                    Brand    = currentProduct.Brand,
                    Quantity = line.QuantityOrdered.ToString(),
                    Sent     = line.QuantityShipped.ToString(),
                    Pack     = currentProduct.Pack,
                    Size     = currentProduct.Size,
                    Price    = priceInfo,
                    Status   = status.ToString()
                };
            }

            itemOrderInfoOOS.Append(itemOOSDetailTemplate.Body.Inject(lineData));
        }
示例#6
0
        /// <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);
        }
示例#7
0
        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);
        }