Exemplo n.º 1
0
        private void UpdateCategoryItems()
        {
            var oldSelectedCategoryItem = _selectedCategoryItem;

            CategoryItems.Clear();
            var allCategoryItem = new Item {
                ID = "-1", Name = "All"
            };

            CategoryItems.Add(new ItemVM {
                Model = allCategoryItem
            });
            using (var context = new ERPContext())
            {
                var categoryItemsFromDatabase = _selectedCategory.Name.Equals("All")
                    ? context.Inventory.Include("Suppliers").OrderBy(item => item.Name)
                    : context.Inventory.Include("Suppliers")
                                                .Where(item => item.ItemCategory.ID.Equals(_selectedCategory.ID))
                                                .OrderBy(item => item.Name);

                foreach (var item in categoryItemsFromDatabase)
                {
                    CategoryItems.Add(new ItemVM {
                        Model = item
                    });
                }
            }

            UpdateSelectedCategoryItem(oldSelectedCategoryItem);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gauna visus Categories iš DB
        /// </summary>
        private void CategoryListGetter()
        {
            var categoriesGetter = CategorySystemManager.NewCategoryGetter();

            categoriesGetter.Result += (status, categories) =>
            {
                if (status == CategoryGetStatus.Success)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        CategoryItems.Clear();
                        CategoryItems.Add(new CategoryModel
                        {
                            Title    = "Visi",
                            Category = null
                        });
                        categories.ForEach(category =>
                        {
                            CategoryItems.Add(new CategoryModel
                            {
                                Title    = category.Title,
                                Category = category,
                            });
                        });
                        //FilterFinal();
                        //CategoryList.IsRefreshing = false;
                    });
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        //CategoryList.IsRefreshing = false;
                    });
                }
            };
            categoriesGetter.Get();
        }
Exemplo n.º 3
0
        public void LoadGoods(string category)
        {
            CategoryItems.Clear();

            string page;

            System.Threading.Thread.Sleep(1000);
            do
            {
                page = helper.GetPageGoods("http://" + helper.loginpage.tbxServer.Text + "/wpproducts/");
                System.Threading.Thread.Sleep(500);
            } while (page.Length < 10);

            page = page.Replace("<HEAD>", "\\").Replace("</HEAD>", "\\").
                   Replace("<BODY>", "\\").Replace("</BODY>", "\\").
                   Replace("<HTML>", "\\").Replace("</HTML>", "\\").
                   Replace("<BR>", "\\");

            List <Product> products = new List <Product>();

            string[] lines = page.Split(new char[] { '\r', '\n', '\\' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var i in lines)
            {
                string[] line = i.Split(new char[] { '|' }, StringSplitOptions.None);


                Product product;
                try
                {
                    product = new Product()
                    {
                        id          = int.Parse(line[0]),
                        name        = line[1],
                        price       = int.Parse(line[2]),
                        category    = line[3],
                        image_url   = line[4],
                        description = line[5],
                    };
                    if (category == "" || category == product.category)
                    {
                        products.Add(product);
                    }
                }
                catch (Exception)
                {
                }
            }

            foreach (var i in products)
            {
                Image       img = new Image();
                BitmapImage src = new BitmapImage();
                string      uri = "http://" + (helper = Helper.GetHelper()).loginpage.tbxServer.Text + i.image_url;
                //string uri = @"http://st.gdefon.com/wallpapers_original/wallpapers/147278_kotik_1680x1050_(www.GdeFon.ru).jpg";
                //string uri = @"/arrowr.png";
                src.UriSource = new Uri(uri, UriKind.RelativeOrAbsolute);
                img.Source    = src;

                //MessageBox.Show(uri);

                ItemViewModel item = new ItemViewModel()
                {
                    LineOne   = i.name,
                    LineTwo   = i.price.ToString(),
                    LineThree = i.category,
                    LineFour  = i.description,
                    LineFive  = i.id.ToString(),

                    LineOneNoCat = i.name.Replace("Стиральная машина ", "").Replace("Ноутбук ", "")
                                   .Replace("Чайник ", "").Replace("Тостер ", ""),
                    LineCat  = Product.CategoryItemToRussian(i.category),
                    LineInfo = Product.CategoryItemToRussian(i.category) + ", " + "$" + i.price.ToString(),

                    ImgUrl = uri,
                    Image  = img
                };
                this.CategoryItems.Add(item);
            }

            //MessageBox.Show(page.Length.ToString() + "\n" +  lines.Length.ToString() + "\n" + page);
        }