public SendEmailWhenUpdatedServiceRequest(IClientsRepository clientsRepository, IMailTemplate mailTemplate, IMailService mailService) { _clientsRepository = clientsRepository; _mailTemplate = mailTemplate; _mailService = mailService; }
public SendEmailWhenSavedClient(IApplicationUserRepository applicationUserRepository, IMailTemplate mailTemplate, IMailService mailService) { _applicationUserRepository = applicationUserRepository; _mailTemplate = mailTemplate; _mailService = mailService; }
/// <summary> /// Queues an email for sending to the specified email address /// </summary> public void Send(string toEmail, string toDisplayName, IMailTemplate template) { var toAddress = new SerializeableMailAddress(toEmail, toDisplayName); var message = _mailMessageRenderer.Render(template, toAddress); _mailDispatchService.Dispatch(message); }
/// <summary> /// Queues an email for sending to the specified email address /// </summary> public async Task SendAsync(string toEmail, string toDisplayName, IMailTemplate template) { var toAddress = new MailAddress(toEmail, toDisplayName); var message = await _mailMessageRenderer.RenderAsync(template, toAddress); await _mailDispatchService.DispatchAsync(message); }
public BookService(IUnitOfWork2 uow, IApplicationSettings appSettings, IRoleService roleService, IUserService userService, IMailingService mailingService, IMailTemplate mailTemplate, IOrganizationService organizationService, IBookInfoService bookInfoService, IBookServiceValidator bookServiceValidator, IBookMobileServiceValidator bookMobileServiceValidator, IAsyncRunner asyncRunner) { _uow = uow; _appSettings = appSettings; _roleService = roleService; _userService = userService; _mailingService = mailingService; _mailTemplate = mailTemplate; _organizationService = organizationService; _booksDbSet = uow.GetDbSet <Book>(); _officesDbSet = uow.GetDbSet <Office>(); _bookLogsDbSet = uow.GetDbSet <BookLog>(); _userDbSet = uow.GetDbSet <ApplicationUser>(); _bookOfficesDbSet = uow.GetDbSet <BookOffice>(); _bookInfoService = bookInfoService; _bookServiceValidator = bookServiceValidator; _serviceValidator = bookMobileServiceValidator; _asyncRunner = asyncRunner; }
private void FormatFromAddress(IMailTemplate template, MailMessage message) { if (template is IMailTemplateWithCustomFromAddress) { message.From = ((IMailTemplateWithCustomFromAddress)template).From; } }
public CommentEmailNotificationService(IUnitOfWork2 uow, IUserService userService, ICommentService commentService, IMailTemplate mailTemplate, IMailingService mailingService, IApplicationSettings appSettings, IOrganizationService organizationService, IMarkdownConverter markdownConverter, IPostService postService, ILogger logger) { _appSettings = appSettings; _userService = userService; _commentService = commentService; _mailTemplate = mailTemplate; _mailingService = mailingService; _organizationService = organizationService; _markdownConverter = markdownConverter; _postService = postService; _logger = logger; _eventsDbSet = uow.GetDbSet <Event>(); _projectsDbSet = uow.GetDbSet <Project>(); _commentsDbSet = uow.GetDbSet <Comment>(); }
public void TestInitializer() { var uow = Substitute.For <IUnitOfWork2>(); _bookOfficesDbSet = Substitute.For <DbSet <BookOffice>, IQueryable <BookOffice>, IDbAsyncEnumerable <BookOffice> >(); uow.GetDbSet <BookOffice>().Returns(_bookOfficesDbSet); _bookLogsDbSet = Substitute.For <DbSet <BookLog>, IQueryable <BookLog>, IDbAsyncEnumerable <BookLog> >(); uow.GetDbSet <BookLog>().Returns(_bookLogsDbSet); _booksDbSet = Substitute.For <DbSet <Book>, IQueryable <Book>, IDbAsyncEnumerable <Book> >(); uow.GetDbSet <Book>().Returns(_booksDbSet); _officesDbSet = Substitute.For <DbSet <Office>, IQueryable <Office>, IDbAsyncEnumerable <Office> >(); uow.GetDbSet <Office>().Returns(_officesDbSet); _userDbSet = Substitute.For <DbSet <ApplicationUser>, IQueryable <ApplicationUser>, IDbAsyncEnumerable <ApplicationUser> >(); uow.GetDbSet <ApplicationUser>().Returns(_userDbSet); _appSettings = Substitute.For <IApplicationSettings>(); _validationService = Substitute.For <IBookMobileServiceValidator>(); _bookInfoService = Substitute.For <IBookInfoService>(); _roleService = Substitute.For <IRoleService>(); _userService = Substitute.For <IUserService>(); _mailingService = Substitute.For <IMailingService>(); _mailTemplate = Substitute.For <IMailTemplate>(); _organizationService = Substitute.For <IOrganizationService>(); _bookServiceValidator = new BookServiceValidator(); var asyncRunner = Substitute.For <IAsyncRunner>(); _bookService = new BookService(uow, _appSettings, _roleService, _userService, _mailingService, _mailTemplate, _organizationService, _bookInfoService, _bookServiceValidator, _validationService, asyncRunner); }
public MailMessage Parse(IMailTemplate template, object model) { var context = new VelocityContext(); var args = GetArgs(model); if (!args.ContainsKey("helper")) { context.Put("helper", new TemplateHelper()); } foreach (var arg in args) { context.Put(arg.Key, arg.Value); } var result = ""; using (var sw = new StringWriter()) { var content = template.ToStringContent(); NVelocityDirectResourceLoader.CurrentEncoding = template.Encoding; var tmp = engine.GetTemplate(content, template.Encoding.EncodingName); tmp.Merge(context, sw); result = sw.ToString(); } return(XmlMailSerializer.Deserialize(result)); }
/// <summary> /// Queues an email for sending to the specified email address /// </summary> public Task SendAsync(string toEmail, string toDisplayName, IMailTemplate template) { var toAddress = new SerializeableMailAddress(toEmail, toDisplayName); var message = _mailMessageRenderer.Render(template, toAddress); return(_mailDispatchService.DispatchAsync(message)); }
public static T ConvertTo <T>(this IMailTemplate source) where T : IMailTemplate, new() { var target = new T(); source.CopyTo(target); return(target); }
private MailMessage Create(IMailTemplate template) { return(new MailMessage() { Subject = template.Subject, Body = template.Body, IsBodyHtml = template.IsBodyHtml }); }
public PendingActivitiesToConfirmed( IActivitiesRepository activitiesRepository, IMailService mailService, IMailTemplate mailTemplate) { _activitiesRepository = activitiesRepository; _mailService = mailService; _mailTemplate = mailTemplate; }
public KudosNotificationService(IUnitOfWork2 uow, IMailingService mailingService, IApplicationSettings appSettings, IMailTemplate mailTemplate) { _appSettings = appSettings; _mailTemplate = mailTemplate; _mailingService = mailingService; _usersDbSet = uow.GetDbSet <ApplicationUser>(); _organizationsDbSet = uow.GetDbSet <Organization>(); }
/// <summary> /// Queues an email for sending to the specified email address /// </summary> public async Task SendAsync(MailAddress address, IMailTemplate template) { if (address == null) { throw new ArgumentNullException(nameof(address)); } await SendAsync(address.Address, address.DisplayName, template); }
public BookRemindService(IUnitOfWork2 uow, IOrganizationService organizationService, IApplicationSettings appSettings, IUserService userService, IMailTemplate mailTemplate, IMailingService mailingService, ILogger logger) { _userService = userService; _organizationService = organizationService; _appSettings = appSettings; _mailTemplate = mailTemplate; _mailingService = mailingService; _booksDbSet = uow.GetDbSet <BookLog>(); _logger = logger; }
internal static Site.MailMessage FromTemplate(IMailTemplate mailTemplate, UserProfile userProfile) { return new TestMailMessage { To = new MailAddress(userProfile.EmailAddress, userProfile.Name), From = new MailAddress("*****@*****.**", "DDD East Anglia"), Subject = mailTemplate.RenderSubjectLine(), Body = mailTemplate.RenderBody() }; }
private void LoadMailTemplate(MailTemplateConfig mailTemplateConfig) { IMailTemplate template = _mailTemplateFactory.GetMailTemplate(); template.IsBodyHtml = mailTemplateConfig.IsBodyHtml; template.Name = mailTemplateConfig.Name; template.Subject = mailTemplateConfig.Subject; template.Body = mailTemplateConfig.Body; _options.Template.AddPrototype(template); }
public MailMessage Parse(IMailTemplate template, object model) { var viewBag = new DynamicViewBag(); viewBag.AddValue("Helper", new TemplateHelper()); var content = template.ToStringContent(); var result = Razor.Parse(content, model, viewBag, template.Location); return(XmlMailSerializer.Deserialize(result)); }
public void SetUp() { Mock <IHostEnvironment> hostEnvironment = new Mock <IHostEnvironment>(); string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); hostEnvironment.Setup(h => h.ContentRootPath).Returns(path); _mailTemplate = new MailTemplate(hostEnvironment.Object, ServiceProvider.GetService <ILogger <MailTemplate> >()); }
public AdministrationUsersNotificationService(IUnitOfWork2 uow, IMailingService mailingService, IApplicationSettings appSettings, IMailTemplate mailTemplate, IUserService permissionService) { _organizationDbSet = uow.GetDbSet <Organization>(); _mailingService = mailingService; _mailTemplate = mailTemplate; _appSettings = appSettings; _userService = permissionService; }
public CommitteeNotificationService(IUnitOfWork2 uow, IMailTemplate mailTemplate, IApplicationSettings appSettings, IMailingService mailingService) { _organizationDbSet = uow.GetDbSet <Organization>(); _mailTemplate = mailTemplate; _appSettings = appSettings; _mailingService = mailingService; _committeeDbSet = uow.GetDbSet <CommitteeEntity>(); _suggestionDbSet = uow.GetDbSet <CommitteeSuggestion>(); }
public static void CopyTo(this IMailTemplate source, IMailTemplate target) { target.Id = source.Id; target.Behaviour = source.Behaviour; target.BodyEncoding = source.BodyEncoding; target.HeaderEncoding = source.HeaderEncoding; target.SubjectEncoding = source.SubjectEncoding; target.Html = source.Html; target.Subject = source.Subject; target.Text = source.Text; target.Title = source.Title; }
public ApplicationUserRepository( ApplicationDbContext dbContext, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IMailTemplate mailTemplate, IMailService mailService ) : base(dbContext) { _userManager = userManager; _signInManager = signInManager; _mailTemplate = mailTemplate; _mailService = mailService; }
public MailMessage Render(IMailTemplate template, SerializeableMailAddress toAddress) { var message = new MailMessage(); message.Subject = template.Subject; message.To = toAddress; FormatFromAddress(template, message); message.TextBody = RenderView(template, "text"); message.HtmlBody = RenderView(template, "html"); return(message); }
public MailSender(IMailTemplate template, List <MailAddress> toAddresses, string subject = null, string body = null) { MailTemplate = template; MailTemplate.ToAddresses = toAddresses; if (!string.IsNullOrEmpty(subject)) { MailTemplate.MessageSubject = subject; } if (!string.IsNullOrEmpty(body)) { MailTemplate.MessageBody = body; } }
/// <summary> /// Renders the contents of a mail template and formats it into a MailMessage /// object that can be used to send out an email. /// </summary> /// <param name="template">The mail template that describes the data and template information for the email</param> /// <param name="toAddress">The address to send the email to.</param> /// <returns>Formatted MailMessage</returns> public async Task <MailMessage> RenderAsync(IMailTemplate template, MailAddress toAddress) { var message = new MailMessage(); message.Subject = template.Subject; message.To = toAddress; FormatFromAddress(template, message); message.TextBody = await RenderViewAsync(template, "text"); message.HtmlBody = await RenderViewAsync(template, "html"); return(message); }
public ServiceRequestNotificationService(IUnitOfWork2 uow, IMailingService mailingService, IMailTemplate mailTemplate, IApplicationSettings appSettings) { _organizationsDbSet = uow.GetDbSet <Organization>(); _usersDbSet = uow.GetDbSet <ApplicationUser>(); _rolesDbSet = uow.GetDbSet <ApplicationRole>(); _serviceRequestStatusDbSet = uow.GetDbSet <ServiceRequestStatus>(); _serviceRequestDbSet = uow.GetDbSet <ServiceRequestModel>(); _mailingService = mailingService; _mailTemplate = mailTemplate; _appSettings = appSettings; }
public EmailMessenger(IPostman postman, IMailTemplate mailTemplate) { if (postman == null) { throw new ArgumentNullException("postman"); } if (mailTemplate == null) { throw new ArgumentNullException("mailTemplate"); } this.postman = postman; this.mailTemplate = mailTemplate; }
public BirthdaysNotificationWebHookService(IUnitOfWork2 uow, IMailingService mailingService, IRoleService roleService, IMailTemplate mailTemplate, IApplicationSettings appSettings) { _usersDbSet = uow.GetDbSet <ApplicationUser>(); _organizationsDbSet = uow.GetDbSet <Organization>(); _date = DateTime.UtcNow; _mailingService = mailingService; _roleService = roleService; _mailTemplate = mailTemplate; _appSettings = appSettings; }
private async Task <string> RenderViewAsync(IMailTemplate template, string type) { var path = string.Format("{0}_{1}.cshtml", template.ViewFile, type); string view = null; try { view = await _viewRenderer.RenderAsync(path, template); } catch (Exception ex) { throw new TemplateRenderException(path, template, ex); } return(view.Trim()); }
private string RenderView(IMailTemplate template, string type) { var path = string.Format("{0}_{1}.cshtml", template.ViewFile, type); string view = null; try { view = _viewRenderer.Render(path, template); } catch (Exception ex) { throw new TemplateRenderException(path, template, ex); } return(view); }
public EmailRepository(IMailTemplate mailTemplate) { _mailTemplate = mailTemplate; }
public EmailMessenger CreateEmailMessenger(IMailTemplate mailTemplate) { return new EmailMessenger(postman, mailTemplate); }