public ActionResult Edit(/*[Bind(Include = "productID,productImage")] */ Product product, FormCollection collection, HttpPostedFileBase upload) { try { // TODO: Add update logic here if (ModelState.IsValid) { if (upload != null) { product.productImage = new byte[upload.ContentLength]; upload.InputStream.Read(product.productImage, 0, upload.ContentLength); } db.Entry(product).State = EntityState.Modified; db.SaveChanges(); ViewBag.result = "Product " + product.vendor + " " + product.productName + " Updated Succesfully!"; ViewBag.prodCategoryID = new SelectList(db.ProductCategories, "prodCategoryID", "categoryName", product.prodCategoryID); return(View(product)); } return(RedirectToAction("Index")); } catch { return(RedirectToAction("Error", "Error")); } }
public ActionResult Edit([Bind(Include = "prodCategoryID,categoryName")] ProductCategory productCategory) { if (ModelState.IsValid) { db.Entry(productCategory).State = EntityState.Modified; db.SaveChanges(); ViewBag.result = "Category " + productCategory.categoryName + " Updated Succesfully!"; return(View(productCategory)); } return(RedirectToAction("Index")); }