public ActionResult EditImg(int?id, HttpPostedFileBase file) { Mazacam prodotti = db.Mazacams.Find(id); if (prodotti == null) { return(HttpNotFound()); } if (file != null) { var extension = Path.GetExtension(file.FileName); if (extension == ".png") { var filename = Server.MapPath("~/Content/Immagini/Mazacam/" + id + extension); file.SaveAs(filename); return(RedirectToAction("Index", "Mazacams")); } else { ViewBag.Message = "Puoi usare solo file con estensione .png"; return(View(prodotti)); } } else { ViewBag.Message = "Devi scegliere un file"; return(View(prodotti)); } }
public ActionResult DeleteConfirmed(int id) { Mazacam mazacam = db.Mazacams.Find(id); db.Mazacams.Remove(mazacam); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Mazacam_Id,Prodotto,Descrizione")] Mazacam mazacam) { if (ModelState.IsValid) { db.Mazacams.Add(mazacam); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mazacam)); }
public ActionResult Edit([Bind(Include = "Mazacam_Id,Prodotto,Posizione", Exclude = "Descrizione")] Mazacam mazacam) { FormCollection collection = new FormCollection(Request.Unvalidated().Form); mazacam.Descrizione = collection["Descrizione"]; if (ModelState.IsValid) { db.Entry(mazacam).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mazacam)); }
// GET: Mazacams/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mazacam mazacam = db.Mazacams.Find(id); if (mazacam == null) { return(HttpNotFound()); } return(View(mazacam)); }
public ActionResult EditImg(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Mazacam prodotti = db.Mazacams.Find(id); if (prodotti == null) { return(HttpNotFound()); } return(View(prodotti)); }