public bool UpdateTemplate(string templateReference, Template template)
        {
            Check.If(templateReference).IsNotNullOrEmpty();
            Check.If(template).IsNotNull();

            return _templateRepository.UpdateTemplate(templateReference, template);
        }
Esempio n. 2
0
        public Response(Email email, Template template)
        {
            EmailUid = email.EmailUid;

            EmailAddresses = new List<EmailAddress>
            {
                new EmailAddress //switch the from address to the the two address
                {
                    Type = EmailAddressType.To,
                    Name = email.FromAddress.Name,
                    Email = email.FromAddress.Email
                },
                new EmailAddress //reply from the specified sender in the template
                {
                    Type = EmailAddressType.From,
                    Name = template.From,
                    Email = template.FromAddress
                }
            };

            Subject = template.Subject;
            HtmlBody = template.HtmlBody;
            PlainTextBody = template.PlainTextBody;
            DateResponded = DateTime.UtcNow;
            OriginalEmail = email.OriginalEmail;
        }
        public string CreateTemplate(Template template)
        {
            Check.If(template).IsNotNull();

            var result = _templateRepository.CreateTemplate(template.CreateReference(_referenceGenerator));

            return result ? template.TemplateReference : null;
        }
        public bool CreateTemplate(Template template)
        {
            if (template.TemplateReference.IsNullOrEmpty())
                return false;

            _autoResponderContext.Templates.Add(template);

            return _autoResponderContext.SaveChanges() > 0;
        }
        public bool UpdateTemplate(string templateReference, Template template)
        {
            var existingTemplate =
                _autoResponderContext.Templates.Active().FirstOrDefault(t => t.TemplateReference == templateReference);

            if (existingTemplate.IsNull())
                return false;

            _templateMapper.Map(template, existingTemplate);

            return _autoResponderContext.SaveChanges() > 0;
        }