public ActionResult Delete(int id) { hypster_tv_DAL.homeSlideshowManager homeSlideshowManager = new hypster_tv_DAL.homeSlideshowManager(); hypster_tv_DAL.homeSlideshow slide = new hypster_tv_DAL.homeSlideshow(); slide = homeSlideshowManager.homeSlideshowByID(id); if (slide.homeSlideshow_ID != 0) { //remove image System.IO.FileInfo del_file = new System.IO.FileInfo(System.Configuration.ConfigurationManager.AppSettings["homeSlideshowStorage_Path"] + "\\" + slide.ImageSrc); del_file.Delete(); homeSlideshowManager.DeleteHomeSlideshow(slide.homeSlideshow_ID); } homeSlideshowManager.ResetSortOrder(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { if (Session["Roles"] != null && Session["Roles"].Equals("Admin")) { hypster_tv_DAL.homeSlideshowManager homeSlideshowManager = new hypster_tv_DAL.homeSlideshowManager(); hypster_tv_DAL.homeSlideshow slide = new hypster_tv_DAL.homeSlideshow(); slide = homeSlideshowManager.homeSlideshowByID(id); if (slide.homeSlideshow_ID != 0) { //remove image System.IO.FileInfo del_file = new System.IO.FileInfo(System.Configuration.ConfigurationManager.AppSettings["homeSlideshowStorage_Path"] + "\\" + slide.ImageSrc); del_file.Delete(); homeSlideshowManager.DeleteHomeSlideshow(slide.homeSlideshow_ID); } homeSlideshowManager.ResetSortOrder(); return(RedirectToAction("Index")); } else { return(RedirectPermanent("/home/")); } }