public ActionResult Brand_page() { int id = (int)Session["brand_id"]; int?f1 = (int)Session["filter1"]; int?f2 = (int)Session["filter2"]; List <Product_Table> prods = new List <Product_Table>(); if (f1 == 1) { prods = db.Product_Table.Where(x => x.SellerId == id & x.ProductIsDeleted == false).OrderBy(x => x.ProductPrice).ToList(); } else if (f2 == 1) { prods = db.Product_Table.Where(x => x.SellerId == id & x.ProductIsDeleted == false).OrderByDescending(x => x.ProductPrice).ToList(); } else { prods = db.Product_Table.Where(x => x.SellerId == id & x.ProductIsDeleted == false).ToList(); } List <int> not_avail_product = new List <int>(); List <Buyer_Product> plist = new List <Buyer_Product>(); foreach (var item in prods) { Buyer_Product obj = new Buyer_Product(); obj.ProductName = item.ProductName; obj.ProductId = item.ProductId; obj.ProductPrice = item.ProductPrice; obj.ProductDesc = item.ProductDesc; if (item.ProductStock <= 0) { not_avail_product.Add(item.ProductId); } Image_Table img = db.Image_Table.Where(x => x.Productid == item.ProductId && x.ImageIsDeleted == false).FirstOrDefault(); obj.BinaryImage = img.BinaryImage; plist.Add(obj); } ViewBag.no_stock = not_avail_product; Session["filter1"] = 0; Session["filter2"] = 0; return(View(plist)); }