Esempio n. 1
0
        public IEnumerable <CustomersActivityReport> GetCustomersActivityReport(string firstName, string lastName, int?minAge, int?maxAge, DateTime?fromDate, DateTime?untilDate)
        {
            var customers = _customersQueryProcessor.Search(firstName, lastName, minAge, maxAge, null, null);
            var report    = customers.Select(x => new CustomersActivityReport
            {
                CoustomerId            = x.Id ?? 0,
                FirstName              = x.FirstName,
                LastName               = x.LastName,
                BirthDate              = x.BirthDate,
                NumberOfOrders         = _ordersQueryProcessor.Search(null, x.Id, null, new int?[] { (int)Consts.Decodes.OrderStatus.Accepted }, null, null, fromDate, untilDate).Count(),
                NumberOfCanceledOrders = _ordersQueryProcessor.Search(null, x.Id, null, new int?[] { (int)Consts.Decodes.OrderStatus.Canceled }, null, null, fromDate, untilDate).Count(),
                NumberOfJoiningAsGuest = _participantsQueryProcessor.Search(x.Id, null, new int?[] { (int)Consts.Decodes.InvitationStatus.Accepted },
                                                                            null, null, null, null, null, null).Count()
            }).ToArray();

            for (int i = 0; i < report.Count(); i++)
            {
                var item      = report[i];
                var itemOrder = _ordersQueryProcessor.Search(null, item.CoustomerId, null, new int?[] { (int)Consts.Decodes.OrderStatus.Accepted }, null, null, null, null);

                if (itemOrder.Count != 0)
                {
                    item.LastGameDate = itemOrder.Max(x => x.StartDate);
                }
            }

            return(report);
        }
Esempio n. 2
0
 public IEnumerable <DTOs.Customer> Search(string firstName = null, string lastName = null, int?minAge = null, int?maxAge = null, int?regionId = null, int?customerId = null)
 {
     return(_customersQueryProcessor.Search(firstName, lastName, minAge, maxAge, regionId, customerId));
 }