public ActionResult Delete(int ID) { if (Session["rolle"] == null || (int)Session["rolle"] < Editor) { return(Redirect("/CMS/Produkt")); } ProduktTabellen produkt = pf.Get(ID); if (produkt.Billede != null) { string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/" + produkt.Billede; if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } pf.Delete(ID); return(Redirect("/CMS/Produkt")); }
public ActionResult Edit(ProduktTabellen input, HttpPostedFileBase Photo) { if (Session["rolle"] == null || (int)Session["rolle"] < Editor) { return(Redirect("/CMS/Produkt")); } input.Billede = null; if (Photo != null) { ProduktTabellen produkt = pf.Get(input.ID); if (produkt.Billede != null) { string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/" + produkt.Billede; if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } string newImagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/"; input.Billede = ft.ImageUpload(Photo, newImagePath); } pf.Update(input); return(Redirect("/CMS/Produkt")); }
public ActionResult AddNew(ProduktTabellen input, HttpPostedFileBase Photo) { if (Session["rolle"] == null || (int)Session["rolle"] < Editor) { return(Redirect("/CMS")); } input.Billede = null; if (Photo != null) { string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Produkter/"; input.Billede = ft.ImageUpload(Photo, imagePath); } pf.Insert(input); return(Redirect("/CMS/Produkt")); }