public ActionResult Delete(int ID) { if (Session["rolle"] == null || (int)Session["rolle"] < Editor) { return(Redirect("/CMS/Kontakt")); } KontaktTabel kontakt = kf.Get(ID); if (kontakt.Billede != null) { string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Kontakt/" + kontakt.Billede; if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } kf.Delete(ID); return(Redirect("/CMS/Kontakt")); }
public ActionResult Edit(KontaktTabel input, HttpPostedFileBase Photo) { if (Session["rolle"] == null || (int)Session["rolle"] < Editor) { return(Redirect("/CMS/Kontakt")); } input.Billede = null; if (Photo != null) { KontaktTabel kontakt = kf.Get(input.ID); if (kontakt.Billede != null) { string imagePath = Request.PhysicalApplicationPath + "/Content/Images/Kontakt/" + kontakt.Billede; if (System.IO.File.Exists(imagePath)) { System.IO.File.Delete(imagePath); } } string newImagePath = Request.PhysicalApplicationPath + "/Content/Images/Kontakt/"; input.Billede = ft.ImageUpload(Photo, newImagePath); } kf.Update(input); return(Redirect("/CMS/Kontakt")); }
public ActionResult AddNew(KontaktTabel 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/Kontakt/"; input.Billede = ft.ImageUpload(Photo, imagePath); } kf.Insert(input); return(Redirect("/CMS/Kontakt")); }