Example #1
0
        public void DeliverInnerCircleRequests()
        {
            //1. Select all unsent Inner Circle notifications/requests
            List <InnerCircle> chosenPeople = _innerCircleRepository.FindAllUnsentRecords();

            //2. Deliver notifications and mark as sent
            foreach (InnerCircle ic in chosenPeople)
            {
                //This would be a great spot for dependency injection
                MailMessage mailMsg = Emailer.GenerateInnerCircleRequestEmail(ic);
                Emailer.SendEmail(mailMsg, ic.Id, EmailEntityType.InnerCircle);
            }

            _innerCircleRepository.Save();
        }
Example #2
0
        public void DeliverOverdueMessages()
        {
            //2. Select all unsent where Date is in the past -- collects event messages too
            List <Message> messages = _msgRepository.FindAllOverdueMessages();

            //3. Deliver messages and mark as sent
            foreach (Message msg in messages)
            {
                //We've got all unsent messages with a past delivery date, so we probably need to send it

                //Go through the message recipients and create the e-mail
                foreach (MessageRecipient msgRecipient in msg.MessageRecipient)
                {
                    //This would be a great spot for dependency injection
                    //All we know is that we have to deliver the message here, we don't care what deliver means
                    MailMessage mailMsg = Emailer.GenerateMessageEmail(msgRecipient);
                    Emailer.SendEmail(mailMsg, msgRecipient.Id, EmailEntityType.MessageRecipient);
                }
            }

            _msgRepository.Save();
        }