Exemplo n.º 1
0
        public virtual void SearchProducts()
        {
            if (AllProducts == null)
            {
                if (Repository == null)
                {
                    throw new ApplicationException("Must set the Repository property.");
                }
                else
                {
                    // Get data from Repository
                    AllProducts = Repository.Search(SearchEntity).OrderBy(p => p.Name).ToList();
                }
            }

            // Get data for the Products collection
            if (SearchEntity == null)
            {
                Products = AllProducts.ToList();
            }
            else
            {
                Products = AllProducts.Where(p => (SearchEntity.Name == null || p.Name.StartsWith(SearchEntity.Name)) && p.ListPrice >= SearchEntity.ListPrice).ToList();
            }
        }
Exemplo n.º 2
0
        override public bool Add_product(int SKU, int count)
        {
            check = ExceptionType.Check_type;
            if (check(SKU))
            {
                throw new ProductException("попытка добавить товар сыпучего типа на склад " + this.name + $" (SKU={SKU})");
                //return false;
            }
            foreach (KeyValuePair <int, int> P in products)
            {
                if (SKU == P.Key)
                {
                    products[P.Key] += count;
                    logger.Info("{0}: пополнение товара {1}({2})", this.name, P.Key, P.Value);
                    return(true);
                }
            }
            Product foundProd = AllProducts.Where(p => p.SKU == SKU).First();

            foundProd.storages.Add(this);
            logger.Info("{0}: поступил новый товар  {1}({2})", this.name, foundProd.name, count);
            products.Add(SKU, count);

            return(true);
        }
Exemplo n.º 3
0
        public void AddProduct(int ID)
        {
            Products p = AllProducts.Where(x => x.ID == ID).First();

            TotalCost += p.Price;
            CheckBalance();
            SelectedProducts.Add(p);
        }
Exemplo n.º 4
0
        #pragma warning disable CS1998 // El método asincrónico carece de operadores "await" y se ejecutará de forma sincrónica
        private async Task SeachText()
        {
        #pragma warning restore CS1998 // El método asincrónico carece de operadores "await" y se ejecutará de forma sincrónica
            try
            {
                if (txtSearch.Length > 2)
                {
                    IsBusy   = true;
                    isSearch = true;

                    var productsSeach = from x in AllProducts
                                        .Where(x => x.products_name.ToUpper().Contains(txtSearch.ToUpper()))
                                        select x;

                    dataProducts = new ObservableCollection <Product>();

                    foreach (var item in productsSeach)
                    {
                        dataProducts.Add(item);
                    }

                    IsBusy = false;
                }
                else
                {
                    if (isSearch)
                    {
                        dataProducts = new ObservableCollection <Product>();

                        foreach (var item in AllProducts)
                        {
                            dataProducts.Add(item);
                        }

                        isSearch = false;
                    }
                }
            }
            finally
            {
                if (dataProducts.Count > 0)
                {
                    isBackVisible = false;
                }
                else
                {
                    isBackVisible = true;
                }

                IsBusy = false;
            }
        }
        public void FillInventoryProductList()
        {
            var products = AllProducts.Where(x => x.InventoryId == SelectedInventory.Id);

            InventoryProductViewModels.Clear();
            foreach (var product in products)
            {
                InventoryProductViewModels.Add(new InventoryProductViewModel
                {
                    Id          = product.Id,
                    ScannedDate = product.ScannedDate,
                    ScannedZone = AvailableZones.First(x => x.Id == product.ZoneId).Description
                });
            }
        }
        private async Task ValidateCategory(string value)
        {
            if (SetProperty(ref selectedItem, value))
            {
                Products = AllProducts.Where(item => item.Category.ToLower() == selectedItem.ToLower()).ToList();
                if (Products.Count == 0)
                {
                    await dialogService.Show("Nothing to show", "In this demo, only watch products are loaded.", "Close");

                    navigationService.NavigateBack();

                    return;
                }
                var items = await GetCartList();

                CartItemCount = items.Count.ToString();
            }
        }
Exemplo n.º 7
0
        override public bool Add_product(int SKU, int count)
        {
            foreach (KeyValuePair <int, int> P in products)
            {
                if (SKU == P.Key)
                {
                    logger.Debug("{0}: пополнение товара {1}({2})", this.name, P.Key, P.Value);
                    products[P.Key] += count;
                    return(true);
                }
            }
            Product foundProd = AllProducts.Where(p => p.SKU == SKU).First();

            foundProd.storages.Add(this);
            logger.Debug("{0}: поступил новый товар  {1}({2})", this.name, foundProd.name, count);
            products.Add(SKU, count);
            return(true);
        }
        private List <ExcelProduct> NotEqualsSearch(SearchParam param, string value)
        {
            switch (param)
            {
            case SearchParam.FeatureName:
                return(AllProducts.Where(p => p.FeatureName != value).ToList());

            case SearchParam.OptionCode:
                return(AllProducts.Where(p => p.OptionCode != value).ToList());

            case SearchParam.OptionGroup:
                return(AllProducts.Where(p => p.OptionGroupName != value).ToList());

            case SearchParam.OptionName:
                return(AllProducts.Where(p => p.OptionName != value).ToList());

            default: return(AllProducts.Where(p => p.OptionCode != value).ToList());
            }
        }
        private List <ExcelProduct> BeginsSearch(SearchParam param, string value)
        {
            switch (param)
            {
            case SearchParam.FeatureName:
                return(AllProducts.Where(p => p.FeatureName.StartsWith(value)).ToList());

            case SearchParam.OptionCode:
                return(AllProducts.Where(p => p.OptionCode.StartsWith(value)).ToList());

            case SearchParam.OptionGroup:
                return(AllProducts.Where(p => p.OptionGroupName.StartsWith(value)).ToList());

            case SearchParam.OptionName:
                return(AllProducts.Where(p => p.OptionName.StartsWith(value)).ToList());

            default: return(AllProducts.Where(p => p.OptionCode.StartsWith(value)).ToList());
            }
        }
Exemplo n.º 10
0
        protected async Task <ObservableCollection <Product> > GetCartList()
        {
            //var email = Preferences.Get("email", "");
            //if (string.IsNullOrEmpty(email))
            //{
            //    return null;
            //}

            var result = await DataStore.GetItemsAsync();

            var cartList = new ObservableCollection <Product>();

            foreach (var productID in result)
            {
                var product = AllProducts.Where(item => item.Id.ToString() == productID).FirstOrDefault();
                if (product != null && !cartList.Contains(product))
                {
                    cartList.Add(product);
                }
                //TODO: Increase order count.
                continue;
            }
            return(cartList);
        }
Exemplo n.º 11
0
 public void RefreshProducts()
 {
     Products = new ObservableCollection <ProductModel>(
         (SelectedProductType != null) ? AllProducts.Where(x => x.Product.ProductType == SelectedProductType) : AllProducts);
 }