Exemple #1
0
        internal ProfileMySpecificOrderPartialVM GetSpecificOrder(int id)
        {
            ProfileMySpecificOrderPartialVM myOrder = new ProfileMySpecificOrderPartialVM();

            OrderArticles[]         orderArticles = OrderArticles.Where(o => o.Oid == id).ToArray();
            List <ProductThumbnail> prodThumbList = new List <ProductThumbnail>();

            myOrder.OrderArticles = new ProductThumbnail[orderArticles.Length];

            foreach (var item in orderArticles)
            {
                bool IsExisting = false;
                if (prodThumbList.Count > 0)
                {
                    foreach (var prod in prodThumbList)
                    {
                        if (item.ArticleNumber == $"{prod.ArticleNrShort}{prod.Size}")
                        {
                            int articleCount = prod.NumberOfSameArticle;
                            articleCount++;

                            prod.NumberOfSameArticle = articleCount;
                            IsExisting = true;
                        }
                    }
                }
                if (!IsExisting)
                {
                    Product currentProduct = Product.First(p => p.ProdArtNr == item.ArticleNumber);
                    Brand   currentBrand   = Brand.First(b => b.BrandId == currentProduct.ProdBrandId);
                    Model   currentModel   = Model.First(m => m.ModelId == currentProduct.ProdModelId);
                    Size    currentSize    = Size.First(s => s.SizeId == currentProduct.ProdSizeId);
                    Color   currentColor   = Color.First(c => c.ColorId == currentProduct.ProdColorId);


                    ProductThumbnail currentThumbnail = new ProductThumbnail
                    {
                        Brand = currentBrand.BrandName,
                        Model = currentModel.ModelName,
                        Price = Convert.ToInt32(currentProduct.ProdPrice),
                        NumberOfSameArticle = 1,
                        Size           = currentSize.SizeName,
                        Color          = currentColor.ColorName,
                        ImgPath        = $"{currentProduct.ProdArtNr.Remove(currentProduct.ProdArtNr.Length - 2)}_1.jpg",
                        ArticleNrShort = currentProduct.ProdArtNr.Substring(0, 5)
                    };
                    prodThumbList.Add(currentThumbnail);
                }
            }

            myOrder.OrderArticles = prodThumbList.ToArray();
            return(myOrder);
        }
Exemple #2
0
        internal ProductProductOverviewVM GetFiltered(ProductProductOverviewVM productVM)
        {
            ProductProductOverviewVM newProductsOverview = GetOverview('i', null);

            ProductThumbnail[] newProducts = newProductsOverview.ProdThumbnails;

            if (productVM.SelectedBrand != "0")
            {
                string brandName = Brand.First(b => b.BrandId == Convert.ToInt32(productVM.SelectedBrand)).BrandName;
                newProducts = newProducts.Where(p => p.Brand == brandName).ToArray();
            }

            if (productVM.SelectedSize != "0")
            {
                string sizeName = Size.First(b => b.SizeId == Convert.ToInt32(productVM.SelectedSize)).SizeName;
                newProducts = newProducts.Where(p => p.Size == sizeName).ToArray();
            }

            if (productVM.SelectedColor != "0")
            {
                string colorName = Color.First(b => b.ColorId == Convert.ToInt32(productVM.SelectedColor)).ColorName;
                newProducts = newProducts.Where(p => p.Color == colorName).ToArray();
            }

            if (productVM.SelectedPrice != "0")
            {
                // newProducts = newProducts.Where(p => p.Price <= Convert.ToInt32(productVM.SelectedPrice)).ToArray();
                switch (productVM.SelectedPrice)
                {
                case "1":
                    newProducts = newProducts.Where(p => p.Price <= 1000).ToArray();
                    break;

                case "2":
                    newProducts = newProducts.Where(p => p.Price <= 1500).ToArray();
                    break;

                case "3":
                    newProducts = newProducts.Where(p => p.Price <= 2000).ToArray();
                    break;

                case "4":
                    newProducts = newProducts.Where(p => p.Price <= 2500).ToArray();
                    break;
                }
            }

            productVM.ProdThumbnails = newProducts;
            return(productVM);
        }
Exemple #3
0
        internal ProductProductItemVM GetProductToView(string articleNum)
        {
            string artNrShort;
            int    specificColor = int.Parse(articleNum[4].ToString());

            if (articleNum.Length == 5)
            {
                Product product = this.Product.Where(p => p.ProdArtNr.StartsWith(articleNum)).Where(p => p.ProdQty > 0).First();

                artNrShort = articleNum;
            }
            else
            {
                artNrShort = articleNum.Remove(articleNum.Length - 2);
            }

            Product currentProduct = this.Product.First(p => p.ProdArtNr.Remove(p.ProdArtNr.Length - 2) == artNrShort);

            var colorArray = GetAllColors(artNrShort.Remove(artNrShort.Length - 1));
            var sizeArray  = GetAllSizes(currentProduct.ProdBrandId, currentProduct.ProdModelId, colorArray.First(c => c.Value == specificColor.ToString()).Text);
            var imageArray = GetAllImages(artNrShort);

            var prodModel = Model.First(m => m.ModelId == currentProduct.ProdModelId).ModelName;
            var prodBrand = Brand.First(b => b.BrandId == currentProduct.ProdBrandId).BrandName;


            var ret = new ProductProductItemVM
            {
                ArticleNum    = artNrShort,
                ColorArray    = colorArray,
                Description   = currentProduct.ProdDescription,
                ImageArray    = imageArray,
                Price         = Convert.ToInt32(currentProduct.ProdPrice),
                Model         = prodModel,
                Brand         = prodBrand,
                SizeArray     = sizeArray,
                SelectedColor = specificColor.ToString()
            };

            return(ret);
        }