public IEnumerable <Order> Get(OrderSearchCriteria criteria) { IQueryable <Order> orders = context.Orders; if (criteria.From.HasValue) { orders = orders.Where(o => o.OrderedDate > criteria.From); } if (criteria.To.HasValue) { orders = orders.Where(o => o.OrderedDate <= criteria.To); } return(orders); }
public async Task SendSalesReportEmailAsync(DateTime date) { var criteria = new OrderSearchCriteria(date.AddDays(-7), date); var orders = orderService.Get(criteria); if (!orders.Any()) { return; } salesReportBuilder.Add(orders); SalesReport report = salesReportBuilder.Create(); IEnumerable <User> recipients = userService.GetBossesRecipients(); var sender = userService.GetBot(); foreach (var recipient in recipients) { await client.SendAsync(sender, recipient, report); } }