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;
     }
 }
 public List<Product> GetProductsByName(int BlockNumber, int BlockSize, string searchValue)
 {
     DataManager dataManager = new DataManager();
     int startIndex = (BlockNumber - 1) * BlockSize;
     var temp =
        dataManager.Check5AttributeLoad(context.Products.Where(x => x.IsActive == true).ToList());
     List<Product> ListOfNone = new List<Product>();
     if (searchValue != null)
     {
         var filter = temp.Where(x => x.Name.ToUpper().Contains(searchValue.ToUpper()));
         var products = filter.Where(x => x.IsActive == true).OrderBy(x => x.ID).Skip(startIndex).Take(BlockSize).ToList();
         if (products.Any())
         {
             return products;
         }
         else if (!products.Any())
         {
             var listNone = context.AliasProducts.Where(x => x.IsActive == true && x.IsMain ==false).OrderBy(x=>x.ProductID).ToList();
             var filterNone = listNone.Where(x => x.Name.ToUpper().Contains(searchValue.ToUpper())).ToList();
             ListOfNone = dataManager.Check5AttributeLoadAnotherName(filterNone).OrderBy(x => x.ID).Skip(startIndex).Take(BlockSize).ToList();
             if (!ListOfNone.Any())
             {
                 WriteToNoResultFile(searchValue);
                 //write to log file
             }
             return ListOfNone;
         }
         return products;
     }
     else
     {
         var filter = temp;
         var products = filter.Where(x => x.IsActive == true).OrderBy(x => x.ID).Skip(startIndex).Take(BlockSize).ToList();
         return products;
     }
 }
 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;
     }
 }
 public List<Product> GetProducts(int BlockNumber, int BlockSize)
 {
     int startIndex = (BlockNumber - 1) * BlockSize;
     var products =
         new DataManager().Check5AttributeLoad(context.Products.Where(x => x.IsActive == true).ToList());
     var filters = products.OrderBy(x => x.TotalWeightPoint).Skip(startIndex).Take(BlockSize).ToList();
     return filters;
 }
        public ActionResult SearchForProduct(string productName)
        {
            LoadDropDownList();
            DataManager manager = new DataManager();
            int BlockSize = 8;

            var products = manager.GetProductsByName(1, BlockSize, productName).ToList();
            return View(products);
        }
 //public ActionResult Index()
 //{
 //    DataManager manager = new DataManager();
 //    int BlockSize = 4;
 //    var products = manager.GetProducts(1, BlockSize);
 //    LoadDropDownList();
 //    return View(products);
 //}
 public ActionResult SearchForProduct()
 {
     DataManager manager = new DataManager();
     int BlockSize = 10;
     var products = manager.GetProducts(1, BlockSize).OrderBy(x => x.TotalWeightPoint).ToList();
     LoadDropDownList();
     return View(products);
 }
 public ActionResult SearchByPriceAndBrand(string brands, string prices)
 {
     int brandInt = 13;// load tat ca  cac thuong hieu
     int priceInt = 8;// load tat ca cac loai gia
     LoadDropDownList();
     if (!String.IsNullOrEmpty(brands))
     {
         brandInt = Int32.Parse(brands);
     }
     if (!String.IsNullOrEmpty(prices))
     {
         priceInt = Int32.Parse(prices);
     }
     if (String.IsNullOrEmpty(prices) && String.IsNullOrEmpty(brands))
     {
         brandInt = 13;
         priceInt = 8;
     }
     var listOFProducts = new List<Product>();
     var brandLaptop = db.Brands.FirstOrDefault(x => x.ID == brandInt);
     var manager = new DataManager();
     int BlockSize = 8;
     if (brandLaptop != null)
     {
         listOFProducts = manager.GetProductsByPrice(1, BlockSize, brandInt, priceInt);
     }
     TempData["brandInt"] = brands;
     TempData["priceInt"] = prices;
     return View(listOFProducts);
 }
 public ActionResult InfinateScrollSearchByPrice(int BlockNumber, int brandID, int priceID)
 {
     //////////////// THis line of code only for demo. Needs to be removed ////
     System.Threading.Thread.Sleep(800);
     //////////////////////////////////////////////////////////////////////////
     int BlockSize = 8;
     var manager = new DataManager();
     var products = manager.GetProductsByPrice(BlockNumber, BlockSize, brandID, priceID);
     var jsonModel = new DataManager.JsonModel
                         {
                             NoMoreData = products.Count < BlockSize,
                             HTMLString = RenderPartialViewToString("ProductList", products)
                         };
     return Json(jsonModel);
 }