Exemplo n.º 1
0
        /// <summary>
        /// Send the specified 'notification' to CHES.
        /// </summary>
        /// <param name="notification"></param>
        /// <returns></returns>
        public async Task <Model.EmailResponse> SendAsync(Model.IEmail email)
        {
            if (email == null)
            {
                throw new ArgumentNullException(nameof(email));
            }
            if (email.To == null || !email.To.Any())
            {
                throw new ArgumentNullException(nameof(email.To));
            }

            var response = await this.Ches.SendEmailAsync(new Ches.Models.EmailModel()
            {
                From     = email.From,
                To       = email.To,
                Cc       = email.Cc,
                Bcc      = email.Bcc,
                Encoding = email.Encoding.ConvertTo <Model.EmailEncodings, Ches.Models.EmailEncodings>(),
                Priority = email.Priority.ConvertTo <Model.EmailPriorities, Ches.Models.EmailPriorities>(),
                BodyType = email.BodyType.ConvertTo <Model.EmailBodyTypes, Ches.Models.EmailBodyTypes>(),
                Subject  = email.Subject,
                Body     = email.Body,
                Tag      = email.Tag,
                SendOn   = email.SendOn,
            });

            return(new Model.EmailResponse(response));
        }
Exemplo n.º 2
0
        public async void SendNotificationAsync_ArgumentException(string key, Pims.Notifications.Models.IEmail email, Type exceptionType)
        {
            // Arrange
            var helper  = new TestHelper();
            var service = helper.Create <NotificationService>();

            var model = new { };

            // Act
            // Assert
            await Assert.ThrowsAsync(exceptionType, async() => await service.SendAsync(key, email, model));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Build the specified 'email' templates and merge the specified 'model'.
 /// Mutate the specified 'email' Subject and Body properties.
 /// Send the notification to CHES.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="templateKey"></param>
 /// <param name="email"></param>
 /// <param name="model"></param>
 /// <returns></returns>
 public async Task <Model.EmailResponse> SendAsync <TModel>(string templateKey, Model.IEmail email, TModel model)
 {
     Build(templateKey, email, model);
     return(await SendAsync(email));
 }