public async Task <byte[]> CreatePreviewAsync(List <int> postIds) { var posts = await _dbContext.Posts .Where(item => postIds.Contains(item.Id)) .Include(item => item.Image) .Include(item => item.Category) .ThenInclude(item => item.Image) .ToListAsync(); return(await _puppeteerService.BuildScreenshotAsync(posts)); }
public async Task <byte[]> CreatePreviewAsync(DateTime date, List <int> articleIds) { if (articleIds.Count > _jumpStartPlanService.MaximumArticlesPerDayCount) { throw new InvalidActionException( $"Maximum {_jumpStartPlanService.MaximumArticlesPerDayCount} articles are allowed per email"); } var articles = await _dbContext.Articles .Include(item => item.Image) .Include(item => item.Category) .ThenInclude(item => item.Image) .Where(item => articleIds.Contains(item.Id)).ToListAsync(); // Keep the order of the articles articles = articles.OrderBy(item => articleIds.IndexOf(item.Id)).ToList(); return(await _puppeteerService.BuildScreenshotAsync(date, articles)); }
public async Task <byte[]> CreatePreviewAsync(int jumpStartId, List <int> articleIds) { var jumpStart = await _dbContext.JumpStarts.FirstOrDefaultAsync(item => item.Id == jumpStartId); if (jumpStart is null) { throw new RecordNotFoundException($"JumpStart {jumpStartId} not found"); } var articles = await _dbContext.Articles .Include(item => item.Image) .Include(item => item.Category) .ThenInclude(item => item.Image) .Where(item => articleIds.Contains(item.Id)).ToListAsync(); // Keep the order of the articles articles = articles.OrderBy(item => articleIds.IndexOf(item.Id)).ToList(); return(await _puppeteerService.BuildScreenshotAsync(jumpStart, articles)); }