public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {

                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {

                    var fileName = Path.GetFileName(file.FileName);
                    string path2 = Path.GetRandomFileName();
                    fileName = path2 + fileName;
                    var path = Path.Combine(Server.MapPath("~/Upload/"), fileName);

                    product.Photo = fileName;

                    file.SaveAs(path);//saved the file
                }

                db.Products.Add(product);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CityId = new SelectList(db.Cities, "Id", "Name", product.CityId);
            return View(product);
        }
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CityId = new SelectList(db.Cities, "Id", "Name", product.CityId);
     return View(product);
 }