Exemple #1
0
        private async void OnSelectedItem()
        {
            ProgressTask progress = null;

            try
            {
                progress = new ProgressTask();
                progress.Show();
                Orders.Clear();
                List <byte> statuses  = null;
                string[]    customers = null;
                string[]    cities    = null;

                if (!string.IsNullOrEmpty(SelectedStatusItems))
                {
                    statuses = SelectedStatusItems.Split(',').ToList().Select(st => Convert.ToByte(st)).ToList();
                }

                if (!string.IsNullOrEmpty(SelectedCustomers))
                {
                    customers = SelectedCustomers.Split(',');
                }

                if (!string.IsNullOrEmpty(SelectedCities))
                {
                    cities = SelectedCities.Split(',');
                }

                if (customers != null && customers.Length > 0 && customers.Length < Customers.Count)
                {
                    _orderFilter.Customers.AddRange(customers);
                }
                if (cities != null && cities.Length > 0 && cities.Length < Cities.Count)
                {
                    _orderFilter.Cities.AddRange(cities);
                }
                if (statuses != null && statuses.Count > 0 && statuses.Count < OrderStatusItems.Count)
                {
                    _orderFilter.OrderStatuses.AddRange(statuses);
                }

                var orders = await _orderFilter.GetOrdersAsync(DateFrom, DateTo);

                _orderFilter.Dispose();

                orders.ForEach(or => Orders.Add(or));
                progress?.Close();
            }
            catch (Exception)
            {
                progress?.Close();
                throw;
            }
        }