public IActionResult Search(int page_index, int page_size, string searchstring)
        {
            var res = (from p in _context.Products
                       where p.ProductName.Contains(searchstring) | p.ProductNumber.Contains(searchstring) | p.Brand.BrandName.Contains(searchstring)
                       orderby p.Id
                       let images =
                           (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                           let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                      let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                     let collection = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                      let brand = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                  let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                              select new Complete_Product()
            {
                Product = p, Images = images, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
            }).ToArray();

            int totalitems = res.Count();
            int totalpages = totalitems / page_size;

            //totalpages+1 because the first page is 1 and not 0
            totalpages = totalpages + 1;
            //string Error = "Error";
            //if (res.Count() < 1 | page_index < 1) return Ok(Error);
            //page_index-1 so the first page is 1 and not 0
            page_index = page_index - 1;
            int skip = page_index * page_size;

            res = res.Skip(skip).Take(page_size).ToArray();
            PaginationPage page = new PaginationPage {
                totalpages = totalpages, totalitems = totalitems, products = res
            };

            return(Ok(page));
        }
Esempio n. 2
0
        public IActionResult GetProductsPerPage(int page_index, int page_size)
        {
            //Get a list of all products with all related info from other tables, ordered by id
            var res = (from p in _context.Products
                       orderby p
                       let images =
                           (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                           let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                      let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                     let collection = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                      let brand = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                  let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                              select new Complete_Product()
            {
                Product = p, Images = images, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
            }).ToArray();


            int totalitems = res.Count();
            int totalpages = totalitems / page_size;

            //totalpages+1 because the first page is 1 and not 0
            totalpages = totalpages + 1;
            string Error = "Error";

            if (res.Count() < 1 | page_index < 1)
            {
                return(Ok(Error));
            }
            //page_index-1 so the first page is 1 and not 0
            page_index = page_index - 1;
            int skip = page_index * page_size;

            res = res.Skip(skip).Take(page_size).ToArray();
            PaginationPage page = new PaginationPage {
                totalpages = totalpages, totalitems = totalitems, products = res
            };

            return(Ok(page));
        }
Esempio n. 3
0
        public IActionResult Blauwe_Burkely_Tassen(int page_index, int page_size)
        {
            var res = (from entries in _context.Products
                       where entries.Brand.BrandName == "Burkely" && entries.ProductColor == "blauw"
                       orderby entries
                       let images = (from images in _context.ProductImages where images.ProductId == entries.Id select images.ImageURL).ToArray()
                                    let type = (from types in _context.Types where entries._TypeId == types.Id select types._TypeName)
                                               let category = (from categories in _context.Categories where categories.Id == entries.CategoryId select categories.CategoryName)
                                                              let collection = (from collections in _context.Collections where collections.Id == entries.Id select collections.CollectionName)
                                                                               let brand = (from brands in _context.Brands where brands.Id == entries.BrandId select brands.BrandName)
                                                                                           let stock = (from stocks in _context.Stock where stocks.Id == entries.StockId select stocks.ProductQuantity)
                                                                                                       select new Complete_Product()
            {
                Product = entries, Images = images, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
            }).ToArray();


            int totalitems = res.Count();
            int totalpages = totalitems / page_size;

            //totalpages+1 because the first page is 1 and not 0
            totalpages = totalpages + 1;
            string Error = "Error";

            if (res.Count() < 1 | page_index < 1)
            {
                return(Ok(Error));
            }
            //page_index-1 so the first page is 1 and not 0
            page_index = page_index - 1;
            int skip = page_index * page_size;

            res = res.Skip(skip).Take(page_size).ToArray();
            PaginationPage page = new PaginationPage {
                totalpages = totalpages, totalitems = totalitems, products = res
            };

            return(Ok(page));
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.TotalPages = (int)Math.Ceiling((double)this.TotalItems / this.ItemCountPerPage);
            this.Pages      = new List <PaginationPage>();
            this.ItemsRight = 3;
            this.ItemsLeft  = 3;

            bool showFirstLink = this.TotalPages > 0 ? true : false;
            bool showLastLink  = this.TotalPages > 0 ? true : false;

            if (this.CurrentPage > this.TotalPages)
            {
                showFirstLink = false;
                showLastLink  = false;
            }

            this.AppendExistedQuery();

            if (this.CurrentPage == 0)
            {
                this.CurrentPage = 1;
            }

            if ((int)this.CurrentPage <= this.ItemsLeft)
            {
                this.ItemsRight += this.ItemsLeft - (int)this.CurrentPage;
            }

            for (int i = 1; i <= this.TotalPages; i++)
            {
                PaginationPage p = new PaginationPage()
                {
                    Value = i, CssClass = "", Url = Request.Url.AbsolutePath + "?" + this.ExistedQuery + "&" + this.QueryKey + "=" + i
                };
                if (this.CurrentPage == p.Value)
                {
                    p.CssClass += this.ActiveCssClass + " ";
                }

                if (p.Value == (int)this.CurrentPage || (p.Value <= ((int)this.CurrentPage + this.ItemsRight) && p.Value > this.CurrentPage) || (p.Value >= ((int)this.CurrentPage - this.ItemsLeft) && p.Value < this.CurrentPage))
                {
                    this.Pages.Add(p);

                    if (p.Value == 1)
                    {
                        showFirstLink = false;
                    }

                    if (p.Value == this.TotalPages)
                    {
                        showLastLink = false;
                    }
                }
            }

            if (showFirstLink == true)
            {
                this.FirstPageUrl = this.GeneratePageUrl("1");
            }

            if (showLastLink == true)
            {
                this.LastPageUrl = this.GeneratePageUrl(this.TotalPages.ToString());
            }

            PaginationRepeater.DataSource = this.Pages;
            PaginationRepeater.DataBind();
        }
Esempio n. 5
0
 public void SetUp()
 {
     _mainPage       = new MainPage(Driver).GoToMainPage();
     _paginationPage = _mainPage.GoToPaginationPage();
 }
Esempio n. 6
0
        public IActionResult GetFilter(
            int page_index,
            int page_size,
            [FromQuery(Name = "BrandId")] int[] BrandId,
            [FromQuery(Name = "ProductColor")] string[] ProductColor,
            [FromQuery(Name = "_TypeId")] int[] _TypeId,
            [FromQuery(Name = "CollectionId")] int[] CollectionId,
            [FromQuery(Name = "CategoryId")] int[] CategoryId
            )
        {
            IQueryable <Complete_Product> res = null;
            var result = _context.Products.Select(m => m);

            if (BrandId.Length != 0)
            {
                result                                                       = result.Where(m => BrandId.Contains(m.BrandId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }
            if (ProductColor.Length != 0)
            {
                result                                                       = result.Where(m => ProductColor.Contains(m.ProductColor));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }
            if (_TypeId.Length != 0)
            {
                result                                                       = result.Where(m => _TypeId.Contains(m._TypeId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }
            if (CategoryId.Length != 0)
            {
                result                                                       = result.Where(m => CategoryId.Contains(m.CategoryId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }
            if (CollectionId.Length != 0)
            {
                result                                                       = result.Where(m => CollectionId.Contains(m.CollectionId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }

            int totalitems = res.Count();
            int totalpages = totalitems / page_size;

            //totalpages+1 because the first page is 1 and not 0
            totalpages = totalpages + 1;
            string Error = "No product that fullfill these filters";

            if (res.Count() < 1 | page_index < 1)
            {
                return(Ok(Error));
            }
            //page_index-1 so the first page is 1 and not 0
            page_index = page_index - 1;
            int skip = page_index * page_size;

            res = res.Skip(skip).Take(page_size);
            PaginationPage page = new PaginationPage {
                totalpages = totalpages, totalitems = totalitems, products = res.ToArray()
            };

            return(Ok(page));
        }
        public IActionResult GetFilter(
            int page_index,
            int page_size,
            [FromQuery(Name = "BrandId")] int[] BrandId,
            [FromQuery(Name = "ProductColor")] string[] ProductColor,
            [FromQuery(Name = "_TypeId")] int[] _TypeId,
            [FromQuery(Name = "CollectionId")] int[] CollectionId,
            [FromQuery(Name = "CategoryId")] int[] CategoryId
            )
        {
            IQueryable <Complete_Product> res = null;
            var result = _context.Products.Select(m => m);

            List <dynamic> FiltersList = new List <dynamic>();

            foreach (string item in ProductColor)
            {
                var LProductColor = (from p in _context.Products where p.ProductColor == item group p by p.ProductColor into Color select new { Productcolor = Color.First().ProductColor });
                FiltersList.Add(LProductColor);
            }
            foreach (int item in BrandId)
            {
                var LBrandName = from b in _context.Brands where b.Id == item group b by b.BrandName into BrandName select new { Brandname = BrandName.First().BrandName };
                FiltersList.Add(LBrandName);
            }
            foreach (int item in _TypeId)
            {
                var LTypeName = from t in _context.Types where t.Id == item group t by t._TypeName into TypeName select new { Typename = TypeName.First()._TypeName };
                FiltersList.Add(LTypeName);
            }
            foreach (int item in CategoryId)
            {
                var LCategoryName = from cat in _context.Categories where cat.Id == item group cat by cat.CategoryName into CategoryName select new { Categoryname = CategoryName.First().CategoryName };
                FiltersList.Add(LCategoryName);
            }
            foreach (int item in CollectionId)
            {
                var LCollectionName = from c in _context.Collections where c.Id == item group c by c.CollectionName into CollectionName select new { Collectionname = CollectionName.First().CollectionName };
                FiltersList.Add(LCollectionName);
            }

            if (BrandId.Length != 0)
            {
                result                                                       = result.Where(m => BrandId.Contains(m.BrandId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }

            if (ProductColor.Length != 0)
            {
                result                                                       = result.Where(m => ProductColor.Contains(m.ProductColor));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }

            if (_TypeId.Length != 0)
            {
                result                                                       = result.Where(m => _TypeId.Contains(m._TypeId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }

            if (CategoryId.Length != 0)
            {
                result                                                       = result.Where(m => CategoryId.Contains(m.CategoryId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }

            if (CollectionId.Length != 0)
            {
                result                                                       = result.Where(m => CollectionId.Contains(m.CollectionId));
                res                                                          = from p in result
                                             let image                       = (from i in _context.ProductImages where p.Id == i.ProductId select i.ImageURL).ToArray()
                                                                    let type = (from t in _context.Types where p._TypeId == t.Id select t._TypeName)
                                                                               let category = (from cat in _context.Categories where p.CategoryId == cat.Id select cat.CategoryName)
                                                                                              let collection                                                             = (from c in _context.Collections where p.CollectionId == c.Id select c.CollectionName)
                                                                                                                                       let brand                         = (from b in _context.Brands where p.BrandId == b.Id select b.BrandName)
                                                                                                                                                               let stock = (from s in _context.Stock where p.StockId == s.Id select s.ProductQuantity)
                                                                                                                                                                           select new Complete_Product()
                {
                    Product = p, Images = image, Type = type, Category = category, Collection = collection, Brand = brand, Stock = stock
                };
            }

            int totalitems = res.Count();
            int totalpages = totalitems / page_size;

            //totalpages+1 because the first page is 1 and not 0
            totalpages = totalpages + 1;
            // string Error = "No product that fullfill these filters";
            // if (res.Count() < 1 | page_index < 1) return Ok(Error);
            //page_index-1 so the first page is 1 and not 0
            page_index = page_index - 1;
            int skip = page_index * page_size;

            res = res.Skip(skip).Take(page_size);
            PaginationPage page = new PaginationPage {
                totalpages = totalpages, totalitems = totalitems, products = res.ToArray()
            };
            FiltersPage filterpage = new FiltersPage {
                FiltersList = FiltersList, page = page
            };

            return(Ok(filterpage));
        }