Пример #1
0
        public async Task SendOrderRequiresApprovalEmail(MessageNotification <OrderSubmitEventBody> messageNotification)
        {
            var order        = messageNotification.EventBody.Order;
            var templateData = new EmailTemplate <OrderTemplateData>()
            {
                Data    = SendgridMappers.GetOrderTemplateData(order, messageNotification.EventBody.LineItems),
                Message = OrderSubmitEmailConstants.GetOrderRequiresApprovalText()
            };

            await SendSingleTemplateEmail(_settings?.SendgridSettings?.FromEmail, messageNotification?.Recipient?.Email, _settings?.SendgridSettings?.OrderApprovalTemplateID, templateData);
        }
Пример #2
0
        public async Task SendOrderDeclinedEmail(MessageNotification <OrderSubmitEventBody> messageNotification)
        {
            var order        = messageNotification.EventBody.Order;
            var approval     = messageNotification.EventBody.Approvals.FirstOrDefault();
            var templateData = new EmailTemplate <OrderTemplateData>()
            {
                Data    = SendgridMappers.GetOrderTemplateData(order, messageNotification.EventBody.LineItems),
                Message = OrderSubmitEmailConstants.GetOrderDeclinedText()
            };

            templateData.Data.Comments = approval.Comments;
            await SendSingleTemplateEmail(_settings?.SendgridSettings?.FromEmail, messageNotification?.Recipient?.Email, _settings?.SendgridSettings?.OrderApprovalTemplateID, templateData);
        }
Пример #3
0
        public async Task SendOrderSubmitEmail(HSOrderWorksheet orderWorksheet)
        {
            var supplierEmailList = await GetSupplierEmails(orderWorksheet);

            var firstName = orderWorksheet.Order.FromUser.FirstName;
            var lastName  = orderWorksheet.Order.FromUser.LastName;

            if (orderWorksheet.Order.xp.OrderType == OrderType.Standard)
            {
                var orderData          = SendgridMappers.GetOrderTemplateData(orderWorksheet.Order, orderWorksheet.LineItems);
                var sellerTemplateData = new EmailTemplate <OrderTemplateData>()
                {
                    Data    = orderData,
                    Message = OrderSubmitEmailConstants.GetOrderSubmitText(orderWorksheet.Order.ID, firstName, lastName, VerifiedUserType.admin)
                };
                var buyerTemplateData = new EmailTemplate <OrderTemplateData>()
                {
                    Data    = orderData,
                    Message = OrderSubmitEmailConstants.GetOrderSubmitText(orderWorksheet.Order.ID, firstName, lastName, VerifiedUserType.buyer)
                };

                var sellerEmailList = await GetSellerEmails();

                //  send emails

                await SendSingleTemplateEmailMultipleRcpts(_settings?.SendgridSettings?.FromEmail, sellerEmailList, _settings?.SendgridSettings?.OrderSubmitTemplateID, sellerTemplateData);
                await SendSingleTemplateEmail(_settings?.SendgridSettings?.FromEmail, orderWorksheet.Order.FromUser.Email, _settings?.SendgridSettings?.OrderSubmitTemplateID, buyerTemplateData);
                await SendSupplierOrderSubmitEmails(orderWorksheet);
            }
            else if (orderWorksheet.Order.xp.OrderType == OrderType.Quote)
            {
                var orderData = SendgridMappers.GetQuoteOrderTemplateData(orderWorksheet.Order, orderWorksheet.LineItems);

                var buyerTemplateData = new EmailTemplate <QuoteOrderTemplateData>()
                {
                    Data    = orderData,
                    Message = OrderSubmitEmailConstants.GetQuoteOrderSubmitText(VerifiedUserType.buyer)
                };
                var supplierTemplateData = new EmailTemplate <QuoteOrderTemplateData>()
                {
                    Data    = orderData,
                    Message = OrderSubmitEmailConstants.GetQuoteOrderSubmitText(VerifiedUserType.supplier)
                };

                //  send emails
                await SendSingleTemplateEmailMultipleRcpts(_settings?.SendgridSettings?.FromEmail, supplierEmailList, _settings?.SendgridSettings?.QuoteOrderSubmitTemplateID, supplierTemplateData);
                await SendSingleTemplateEmail(_settings?.SendgridSettings?.FromEmail, orderWorksheet.Order.FromUser.Email, _settings?.SendgridSettings?.QuoteOrderSubmitTemplateID, buyerTemplateData);
            }
        }
Пример #4
0
        private async Task SendSupplierOrderSubmitEmails(HSOrderWorksheet orderWorksheet)
        {
            ListPage <HSSupplier> suppliers = null;

            if (orderWorksheet.Order.xp.SupplierIDs != null)
            {
                var filterString = String.Join("|", orderWorksheet.Order.xp.SupplierIDs);
                suppliers = await _oc.Suppliers.ListAsync <HSSupplier>(filters : $"ID={filterString}");
            }
            foreach (var supplier in suppliers.Items)
            {
                if (supplier?.xp?.NotificationRcpts?.Count() > 0)
                {
                    // get orderworksheet for supplier order and fill in some information from buyer order worksheet
                    var supplierOrderWorksheet = await BuildSupplierOrderWorksheet(orderWorksheet, supplier.ID);

                    var supplierTemplateData = new EmailTemplate <OrderTemplateData>()
                    {
                        Data    = SendgridMappers.GetOrderTemplateData(supplierOrderWorksheet.Order, supplierOrderWorksheet.LineItems),
                        Message = OrderSubmitEmailConstants.GetOrderSubmitText(orderWorksheet.Order.ID, supplierOrderWorksheet.Order.FromUser.FirstName, supplierOrderWorksheet.Order.FromUser.LastName, VerifiedUserType.supplier)
                    };

                    // SEB-Specific Data
                    ((OrderTemplateData)supplierTemplateData.Data).BillTo = new Address()
                    {
                        CompanyName = "SEB Vendor Portal - BES",
                        Street1     = "8646 Eagle Creek Circle",
                        Street2     = "Suite 107",
                        City        = "Savage",
                        State       = "MN",
                        Zip         = "55378",
                        Phone       = "877-771-9123",
                        xp          =
                        {
                            Email = "*****@*****.**"
                        }
                    };

                    var supplierTos = new List <EmailAddress>();
                    foreach (var rcpt in supplier.xp.NotificationRcpts)
                    {
                        supplierTos.Add(new EmailAddress(rcpt));
                    }
                    ;
                    await SendSingleTemplateEmailMultipleRcpts(_settings?.SendgridSettings?.FromEmail, supplierTos, _settings?.SendgridSettings?.OrderSubmitTemplateID, supplierTemplateData);
                }
            }
        }