示例#1
0
        public MessagingMessageModel GetMailMessage(Guid messageId)
        {
            MessagingMessage      message    = this.UnitOfWork.MessagingMessageRepository.GetById(messageId);
            MessagingMessageModel messageDto = AutoMapper.Mapper.Map <MessagingMessage, MessagingMessageModel>(message);

            return(messageDto);
        }
示例#2
0
        public MessagingMessageModel GetMailMessage(Guid templateId, Dictionary <string, string> values)
        {
            MessagingTemplateContent messageTemplate = this.GetAvailableMessageTemplate(templateId);

            if (messageTemplate == null)
            {
                throw new InvalidOperationException(String.Format("Invalid Email Template: {0}", templateId));
            }

            MessagingMessage message = new MessagingMessage()
            {
                Id = Guid.NewGuid(),
                MessagingTemplateContentId = messageTemplate.Id,
                MessagingSubject           = databindingHelper.bind(messageTemplate.MessagingSubject, values),
                MessagingFromName          = databindingHelper.bind(messageTemplate.MessagingFromName, values),
                MessagingFromEmailAddress  = databindingHelper.bind(messageTemplate.MessagingFromEmailAddress, values),
                MessagingTo      = databindingHelper.bind(messageTemplate.MessagingTo, values),
                MessagingCc      = databindingHelper.bind(messageTemplate.MessagingCc, values),
                MessagingBcc     = databindingHelper.bind(messageTemplate.MessagingBcc, values),
                MessagingContent = databindingHelper.bind(messageTemplate.MessagingContent, values),
                Tags             = messageTemplate.Tags,
                IsSent           = false,
                IsMarkedAsRead   = false,
                SentDate         = null,
                CreatedDate      = DateTime.UtcNow
            };

            this.UnitOfWork.MessagingMessageRepository.Insert(message);
            this.UnitOfWork.SaveChanges();

            MessagingMessageModel model = Mapper.Map <MessagingMessage, MessagingMessageModel>(message);

            return(model);
        }
示例#3
0
        private void UpdateMessagingMessage(MessagingMessageModel message)
        {
            MessagingMessage msg = new MessagingMessage()
            {
                Id = message.Id,
                EmailDeliveryProvider = Sender.ToString(),
                IsSent   = true,
                SentDate = DateTime.UtcNow
            };

            this.UnitOfWork.MessagingMessageRepository.Update(msg, x => x.IsSent, x => x.SentDate, x => x.EmailDeliveryProvider);
            this.UnitOfWork.SaveChanges();
        }