public ActionResult DeletePostGallery(int postId, int id) { ActionResult actionResult; if (!base.Request.IsAjaxRequest()) { return(base.Json(new { success = false })); } try { PostGallery galleryImage = this._postGalleryService.Get((PostGallery x) => x.PostId == postId && x.Id == id, false); _postGalleryService.Delete(galleryImage); string path1 = base.Server.MapPath(string.Concat("~/", galleryImage.ImageBigSize)); string path2 = base.Server.MapPath(string.Concat("~/", galleryImage.ImageMediumSize)); string path3 = base.Server.MapPath(string.Concat("~/", galleryImage.ImageSmallSize)); System.IO.File.Delete(path1); System.IO.File.Delete(path2); System.IO.File.Delete(path3); actionResult = base.Json(new { success = true }); } catch (Exception ex) { actionResult = base.Json(new { success = false, messages = ex.Message }); } return(actionResult); }
public ActionResult DeletePostGallery(int postId, int id) { if (!Request.IsAjaxRequest()) { return(Json(new { success = false })); } ActionResult actionResult; try { var postGallery = _postGalleryService.Get(x => x.PostId == postId && x.Id == id); _postGalleryService.Delete(postGallery); var path1 = Server.MapPath(string.Concat("~/", postGallery.ImageBigSize)); var path2 = Server.MapPath(string.Concat("~/", postGallery.ImageMediumSize)); var path3 = Server.MapPath(string.Concat("~/", postGallery.ImageSmallSize)); System.IO.File.Delete(path1); System.IO.File.Delete(path2); System.IO.File.Delete(path3); actionResult = Json(new { success = true }); } catch (Exception ex) { actionResult = Json(new { success = false, messages = ex.Message }); } return(actionResult); }