コード例 #1
0
        private void OnAddedToMailingList(AddedToMailingList addedToMailingListEvent)
        {
            if (addedToMailingListEvent == null)
                throw new ArgumentNullException("addedToMailingListEvent");

            FirstName = addedToMailingListEvent.FirstName;
            LastName = addedToMailingListEvent.LastName;
            Email = addedToMailingListEvent.Email;
            HtmlEmail = addedToMailingListEvent.HtmlEmail;
        }
コード例 #2
0
        public bool Process(RequestMailingCommand command, bool sendEmailNotice=true)
        {
            bool mailingListSuccess = false;
            bool mailSuccess =false;

            // TODO: create RequestMailingEvent, then RequestMailingEvent handler
            // TODO: Add Versant Database code here...
            try
            {
                var mailingListEntry = new MailingListEntry(Guid.NewGuid());

                mailingListSuccess = AddUserToMailingList(command);

                var e = new AddedToMailingList
                            {
                                StreamId = mailingListEntry.Id,
                                FirstName = command.FirstName,
                                LastName = command.LastName,
                                Email = command.Email
                            };

                MueVueEvents.Add(e);
                mailingListEntry.OnReceiving(e);
            }
            catch (Exception ex)
            {
                logger.Error("Failed to add new user to MailChimp", ex);
            }

            if (sendEmailNotice)
            {
                try
                {
                    logger.Debug("Calling SmtpMail.send()");
                    //SmtpMail.Send("*****@*****.**", "MailingList Request", command.ToString(), command.Email);
                    mailSuccess = true;
                }
                catch (Exception ex)
                {
                    logger.ErrorException("SmtpEmail.Send() failed: ", ex);
                    logger.Error("Failed to send email", ex);
                }
            }

            var success = mailingListSuccess || mailSuccess;

            logger.Info("MailingList - eventstore: {0}, mailing: {1}", mailingListSuccess, mailSuccess);
            logger.Info("Request: {0}", command.ToString());
            return success;
        }