public override void SelectOrders(OrderFilter orderFilter, ref List <Order> orders)
 {
     if (orders.Count == 0 && orderFilter.GetCountItemsNexFilter(_nextOrderSelector) == 0)
     {
         // if orderFilter.OrderStatuses.Count == 0 get all orders by OrderDate
         if (orderFilter.OrderStatuses.Count == 0)
         {
             orders.AddRange(orderFilter.GetDefaultOrders());
         }
         else
         {
             orders = GetOrdersByOrderStatus(orderFilter, FactoryRepositoryFactory.GetFactory().OrderRepository.Orders);
         }
     }
     else
     {
         // if OrderStatuses.Count == 0 skip select orders. Filter is disabled.
         if (orderFilter.OrderStatuses.Count > 0)
         {
             if (orders.Count == 0)
             {
                 orders = GetOrdersByOrderStatus(orderFilter, FactoryRepositoryFactory.GetFactory().OrderRepository.Orders);
             }
             else
             {
                 orders = GetOrdersByOrderStatus(orderFilter, orders);
             }
         }
     }
     base.SelectOrders(orderFilter, ref orders);
 }
 public override void SelectOrders(OrderFilter orderFilter, ref List <Order> orders)
 {
     // get all orders by OrderDate
     if (orderFilter.Customers.Count == 0 && orderFilter.OrderStatuses.Count == 0 && orderFilter.Cities.Count == 0)
     {
         orders.AddRange(orderFilter.GetDefaultOrders());
     }
     else
     {
         base.SelectOrders(orderFilter, ref orders);
     }
 }
            private static List <Order> GetOrdersByOrderStatus(OrderFilter orderFilter, IReadOnlyCollection <Order> orders)
            {
                var ordersWithStatus = new List <Order>();

                foreach (var orderStatuse in orderFilter.OrderStatuses)
                {
                    Thread.Sleep(100);

                    var ords = from or in orders
                               where or.OrderStatus.Status.Equals(orderStatuse)
                               select or;
                    ordersWithStatus.AddRange(ords);
                }

                return(ordersWithStatus);
            }
            private static List <Order> GetOrdersByCustomer(OrderFilter orderFilter, IReadOnlyCollection <Order> source)
            {
                var ordersWithCustomers = new List <Order>();

                foreach (var city in orderFilter.Cities)
                {
                    Thread.Sleep(100);

                    var ords = from or in source
                               where or.City.Name.Equals(city)
                               select or;
                    ordersWithCustomers.AddRange(ords);
                }

                return(ordersWithCustomers);
            }
 public virtual void SelectOrders(OrderFilter orderFilter, ref List <Order> orders)
 {
     NextOrderSelector?.SelectOrders(orderFilter, ref orders);
 }