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);
 }
Пример #2
0
        public MainWindowViewModel(FrameworkElement element)
        {
            _orderFilter = new OrderFilter();
            DateFrom     = DateTime.Now;
            DateTo       = DateTime.Now;

            Orders              = new BindingList <Order>();
            OrderStatusItems    = FactoryRepositoryFactory.GetFactory().OrderStatusItemRepository.OrderStatusItems;
            Customers           = FactoryRepositoryFactory.GetFactory().CustomerRepository.Customers;
            Cities              = FactoryRepositoryFactory.GetFactory().CityRepository.Cities;
            SelectedItemCommand = new DeligateCommand(OnSelectedItem, p => OrderStatusItems.Count > 0 && Customers.Count > 0);

            element.DataContext = this;
        }
        protected IEnumerable <Order> GetDefaultOrders()
        {
            try
            {
                Thread.Sleep(2000);
                var ordersWithDate =
                    FactoryRepositoryFactory.GetFactory().OrderRepository.Orders.Where(
                        or => or.OrderDate >= DtFrom && or.OrderDate <= DtTo);

                return(ordersWithDate);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #4
0
        private static List <Order> GetOrders(int countOrders)
        {
            try
            {
                var rn     = new Random();
                var rn2    = new Random();
                var rn3    = new Random();
                var rn4    = new Random();
                var rn5    = new Random();
                var rn6    = new Random();
                var orders = new List <Order>();

                for (var i = 0; i < countOrders; i++)
                {
                    Thread.Sleep(10);
                    var order = new Order
                    {
                        Id       = i + 1,
                        Customer = FactoryRepositoryFactory.GetFactory().CustomerRepository.Customers[
                            rn.Next(FactoryRepositoryFactory.GetFactory().CustomerRepository.Customers.Count)],
                        NumberOrder = $"A0{rn2.Next()}",
                        OrderDate   = new DateTime(DateTime.Now.Year, rn3.Next(1, 12), rn4.Next(1, 31)),
                        OrderStatus = FactoryRepositoryFactory.GetFactory().OrderStatusItemRepository.OrderStatusItems[
                            rn5.Next(
                                FactoryRepositoryFactory.GetFactory()
                                .OrderStatusItemRepository.OrderStatusItems.Count)],
                        City = FactoryRepositoryFactory.GetFactory().CityRepository.Cities[rn6.Next(FactoryRepositoryFactory.GetFactory().CityRepository.Cities.Count)]
                    };
                    orders.Add(order);
                }

                return(orders);
            }
            catch (Exception)
            {
                throw;
            }
        }