public ActionResult Create(Product product)
        {
            //if (ModelState.IsValid)
            //{
                HttpPostedFileBase file = Request.Files["ImageUpload"];

                product.ProductID = Guid.NewGuid();
                product.CreateDate = DateTime.Now;
                product.ModifiedDate = DateTime.Now;

                if (file != null && file.FileName != null && file.FileName != "")
                {
                    FileInfo fi = new FileInfo(file.FileName);
                    if (fi.Extension != ".jpeg" && fi.Extension != ".jpg")
                    {
                        TempData["Errormsg"] = "Image File Extension is Not valid";
                        return View(product);
                    }
                    else
                    {
                        product.ProductImage = product.ProductID + fi.Extension;
                        file.SaveAs(Server.MapPath("~/Content/" + product.ProductID + fi.Extension));
                    }
                }
                db.Products.Add(product);
                db.SaveChanges();
                return RedirectToAction("Index");
            //}

            //ViewBag.SubcategoyID = new SelectList(db.SubCategories, "SubCategoryID", "SubCategoryName", product.SubcategoyID);
            return View(product);
        }
 public ActionResult Edit(Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.SubcategoyID = new SelectList(db.SubCategories, "SubCategoryID", "SubCategoryName", product.SubcategoyID);
     return View(product);
 }