示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }