Exemplo n.º 1
0
        private void LoadDisplayedSuppliersAccordingToSelectedCategoryItem()
        {
            var suppliersFromDatabase = new List <Supplier>();

            using (var context = new ERPContext())
            {
                if (_selectedCategoryItem.Name.Equals("All") && _selectedCategory.Name.Equals("All"))
                {
                    suppliersFromDatabase = context.Suppliers.Include("Items").Where(supplier => !supplier.Name.Equals("-")).ToList();
                }

                else if (_selectedCategoryItem.Name.Equals("All") && !_selectedCategory.Name.Equals("All"))
                {
                    foreach (
                        var supplier in
                        CategoryItems.Where(item => item.Suppliers != null)
                        .SelectMany(
                            item => item.Suppliers.Where(supplier => !suppliersFromDatabase.Contains(supplier)))
                        )
                    {
                        suppliersFromDatabase.Add(supplier);
                    }
                }

                else
                {
                    foreach (var categoryItem in CategoryItems.Where(item => !item.Name.Equals("All")))
                    {
                        foreach (var supplier in categoryItem.Suppliers)
                        {
                            if (!suppliersFromDatabase.Contains(supplier))
                            {
                                suppliersFromDatabase.Add(supplier);
                            }
                        }
                    }
                }
            }

            foreach (var supplier in suppliersFromDatabase.Where(
                         supplier => supplier.IsActive.Equals(_isActiveChecked))
                     .OrderBy(supplier => supplier.Name))
            {
                DisplayedSuppliers.Add(new SupplierVM {
                    Model = supplier
                });
            }
        }
Exemplo n.º 2
0
        private async Task <IEnumerable <IIndexItem> > GetIndexItemsAsync()
        {
            int page = (IndexItems.Count + PageSize - 1) / PageSize;

            return(await Book.QueryIndex(Pattern, CategoryItems.Where(item => item.Selected), page));
        }