public ActionResult Edit(Product product, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    product.Img = SaveFiles.SaveImageFile(file); ;
                }
                Market.DbContext.Entry(product).State = EntityState.Modified;
                try
                {
                    Market.DbContext.SaveChanges();
                }
                catch
                {

                    return View("Error");
                }
                return RedirectToAction("Browse", "Home",
                    new { Category = Market.DbContext.Categories.Find(product.CategoryId).Name,
                        page = GetPageNumber(product), pageSize = TempData["PageSize"] });
            }
            ViewBag.CategoryId = new SelectList(Market.DbContext.Categories, "CategoryId", "Name", product.CategoryId);
            return View(product);
        }
 public decimal GetPageNumber(Product product)
 {
     string categoryName = Market.DbContext.Categories.Find(product.CategoryId).Name;
         List<Product> products = Market.DbContext.Products.Where(c => c.Category.Name == categoryName).ToList();
         decimal indexProduct = products.IndexOf(product) + 1;
         decimal pageNumber = Math.Ceiling(indexProduct / int.Parse(TempData["PageSize"].ToString()));
         return pageNumber;
 }