async Task SendNewsletters(BlogPost post) { var pager = new Pager(1, 1000); IEnumerable <Newsletter> newsletters; newsletters = await _data.Newsletters.GetList(e => e.Id > 0, pager); var emails = newsletters.Select(i => i.Email).ToList(); if (emails != null && emails.Count > 0) { var siteUrl = $"{Request.Scheme}://{Request.Host}{Request.PathBase}"; await _newsletter.SendNewsletters(post, emails, siteUrl); } }
async Task SendNewsletters(BlogPost post) { var pager = new Pager(1, 1000); IEnumerable <Newsletter> newsletters; newsletters = await _data.Newsletters.GetList(e => e.Id > 0, pager); var emails = newsletters.Select(i => i.Email).ToList(); if (emails != null && emails.Count > 0) { var siteUrl = Request.ExtractAbsoluteUri(); await _newsletter.SendNewsletters(post, emails, siteUrl); } }
public async Task <int> SendNewsletters(int postId) { var pager = new Pager(1, 10000); var items = await _data.Newsletters.GetList(e => e.Id > 0, pager); var emails = items.Select(i => i.Email).ToList(); int count = 0; if (emails.Count > 0) { var blogPost = _data.BlogPosts.Single(p => p.Id == postId); string baseUrl = $"{Request.Scheme}://{Request.Host}{Request.PathBase}/"; count = await _newsletterService.SendNewsletters(blogPost, emails, baseUrl); } return(count); }
async Task SendNewsletters(BlogPost post) { var pager = new Pager(1, 1000); IEnumerable <Newsletter> newsletters; newsletters = await _data.Newsletters.GetList(e => e.Id > 0, pager); var emails = newsletters.Select(i => i.Email).ToList(); if (emails != null && emails.Count > 0) { var siteUrl = $"{Request.Scheme}://{Request.Host}{Request.PathBase}"; await _newsletter.SendNewsletters(post, emails, siteUrl); } Log.Information("{prefix}: Sent newletters for post with Id: {id}", FilterPrefixes.NEWS, post.Id); }