コード例 #1
0
 public List<Product> ListOfTop3ProductbyPrice(int brandID, int value)
 {
     var listOFProducts = new List<Product>();
     var temp = new DataManager().Check5AttributeLoad(context.Products.Where(x => x.IsActive == true).ToList());
     if (brandID != 13)
     {
         // Price from  < 8 mil
         if (value == 1)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID && x.Price < _8M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   8 mil < 10 mil
         else if (value == 2)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                && x.Price > _8M
                && x.Price <= _10M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   10 mil < 13 mil
         else if (value == 3)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _10M
                 && x.Price <= _13M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   13 mil < 16 mil
         else if (value == 4)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _13M
                 && x.Price <= _16M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   16 mil < 20 mil
         else if (value == 5)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                && x.Price > _16M
                && x.Price <= _20M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   20 mil < 25 mil
         else if (value == 6)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _20M
                 && x.Price <= _25M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   > 25 mil
         else if (value == 7)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _25M).ToList();
             listOFProducts = filterProduct;
         }
         else if (value == 8)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID).ToList();
             listOFProducts = filterProduct;
         }
         return listOFProducts;
     }
     else
     {
         // Price from  < 8 mil
         if (value == 1)
         {
             var filterProduct = temp.Where(x => x.Price < _8M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   8 mil < 10 mil
         else if (value == 2)
         {
             var filterProduct = temp.Where(x => x.Price > _8M
                && x.Price <= _10M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   10 mil < 13 mil
         else if (value == 3)
         {
             var filterProduct = temp.Where(x => x.Price > _10M
                 && x.Price <= _13M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   13 mil < 16 mil
         else if (value == 4)
         {
             var filterProduct = temp.Where(x => x.Price > _13M
                 && x.Price <= _16M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   16 mil < 20 mil
         else if (value == 5)
         {
             var filterProduct = temp.Where(x => x.Price > _16M
                && x.Price <= _20M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   20 mil < 25 mil
         else if (value == 6)
         {
             var filterProduct = temp.Where(x => x.Price > _20M
                 && x.Price <= _25M).ToList();
             listOFProducts = filterProduct;
         }
         // Price from   > 25 mil
         else if (value == 7)
         {
             var filterProduct = temp.Where(x => x.Price > _25M).ToList();
             listOFProducts = filterProduct;
         }
         else if (value == 8)
         {
             listOFProducts = temp;
         }
         return listOFProducts;
     }
 }
コード例 #2
0
 public List<Product> GetProductsByPrice(int BlockNumber, int BlockSize, int brandID, int value)
 {
     var ListOFProducts = new List<Product>();
     int startIndex = (BlockNumber - 1) * BlockSize;
     var temp = new DataManager().Check5AttributeLoad(context.Products.Where(x => x.IsActive == true).ToList());
     if (brandID != 13)
     {
         // Price from  < 8 mil
         if (value == 1)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID && x.Price < _8M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   8 mil < 10 mil
         else if (value == 2)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                && x.Price > _8M
                && x.Price <= _10M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   10 mil < 13 mil
         else if (value == 3)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _10M
                 && x.Price <= _13M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   13 mil < 16 mil
         else if (value == 4)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _13M
                 && x.Price <= _16M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   16 mil < 20 mil
         else if (value == 5)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                && x.Price > _16M
                && x.Price <= _20M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   20 mil < 25 mil
         else if (value == 6)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _20M
                 && x.Price <= _25M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   > 25 mil
         else if (value == 7)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID
                 && x.Price > _25M).ToList();
             ListOFProducts = filterProduct;
         }
         else if (value == 8)
         {
             var filterProduct = temp.Where(x => x.BrandID == brandID).ToList();
             ListOFProducts = filterProduct;
         }
         var products = ListOFProducts.Where(x => x.IsActive == true).OrderBy(x => x.ID).Skip(startIndex).Take(BlockSize).ToList();
         return products;
     }
     else
     {
         // Price from  < 8 mil
         if (value == 1)
         {
             var filterProduct = temp.Where(x => x.Price < _8M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   8 mil < 10 mil
         else if (value == 2)
         {
             var filterProduct = temp.Where(x => x.Price > _8M
                && x.Price <= _10M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   10 mil < 13 mil
         else if (value == 3)
         {
             var filterProduct = temp.Where(x => x.Price > _10M
                 && x.Price <= _13M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   13 mil < 16 mil
         else if (value == 4)
         {
             var filterProduct = temp.Where(x => x.Price > _13M
                 && x.Price <= _16M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   16 mil < 20 mil
         else if (value == 5)
         {
             var filterProduct = temp.Where(x => x.Price > _16M
                && x.Price <= _20M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   20 mil < 25 mil
         else if (value == 6)
         {
             var filterProduct = temp.Where(x => x.Price > _20M
                 && x.Price <= _25M).ToList();
             ListOFProducts = filterProduct;
         }
         // Price from   > 25 mil
         else if (value == 7)
         {
             var filterProduct = temp.Where(x => x.Price > _25M).ToList();
             ListOFProducts = filterProduct;
         }
         else if (value == 8)
         {
             ListOFProducts = temp;
         }
         var products = ListOFProducts.Where(x => x.IsActive == true).OrderBy(x => x.ID).Skip(startIndex).Take(BlockSize).ToList();
         return products;
     }
 }