public IEnumerable <IMailMessageInfo> Compose()
        {
            List <IMailMessageInfo> mailMessageList = new List <IMailMessageInfo>();

            //List all customers
            List <Customer> customers = DataLayer.ListCustomers();

            //List all new customers
            List <Customer> newCustomers = customers.Where(c => c.CreatedDateTime > DateTime.Now.AddDays(-1)).ToList();

            //loop through list of new customers
            foreach (var customer in newCustomers)
            {
                //Create a new MailMessage
                MailMessageInfo msgInfo = new MailMessageInfo();
                //Add customer to reciever list
                msgInfo.AddMailIdToReceiverList(customer.Email);
                //Add subject
                msgInfo.Subject = "Welcome as a new customer at EO!";
                //Send mail from [email protected]
                msgInfo.From = "*****@*****.**";
                //Add body to mail
                msgInfo.Body = "Hi " + customer.Email +
                               "<br>We would like to welcome you as customer on our site!<br><br>Best Regards,<br>EO Team";

                mailMessageList.Add(msgInfo);
            }

            return(mailMessageList);
        }
Beispiel #2
0
        public IEnumerable <IMailMessageInfo> Compose()
        {
            List <IMailMessageInfo> mailMessageList = new List <IMailMessageInfo>();

            //List all customers
            List <Customer> customers = DataLayer.ListCustomers();
            //List all orders
            List <Order> orders = DataLayer.ListOrders();

            //Identify customer who hasn't put an order
            List <Customer> customerWitoutOrder = customers.Where(
                c => !orders.Any(o => o.CustomerEmail.Equals(c.Email, StringComparison.OrdinalIgnoreCase))).ToList();

            foreach (var customer in customerWitoutOrder)
            {
                //Create a new Mail Message Info
                MailMessageInfo msgInfo = new MailMessageInfo();
                //Add customer to reciever list
                msgInfo.AddMailIdToReceiverList(customer.Email);
                //Add subject
                msgInfo.Subject = "We miss you as a customer";
                //Send mail from [email protected]
                msgInfo.From = "*****@*****.**";
                //Add body to mail
                msgInfo.Body = "Hi " + customer.Email +
                               "<br>We miss you as a customer. Our shop is filled with nice products. Here is a voucher that gives you 50 kr to shop for." +
                               "<br>Voucher: " + this.Voucher +
                               "<br><br>Best Regards,<br>EO Team";

                mailMessageList.Add(msgInfo);
            }

            return(mailMessageList);
        }