public JsonResult DeleteVideoWithPath(int idVideo, String poth) { Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("deleteVideo.Media.Entrée(idVideo: {0})", idVideo)); var videoPath = poth; var video = DALMedia.FindVideoById(idVideo); if (video != null) { try { videoPath = videoPath + video.nom + "." + video.format; DALMedia.DeleteVideo(video.Id); if (System.IO.File.Exists(videoPath)) { System.IO.File.Delete(videoPath); } Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("deleteVideo.Media.Sortie(videoPath: {0})", videoPath)); } catch (Exception e) { Tools.Logger.Ecrire(Tools.Logger.Niveau.Erreur, string.Format("deleteVideo.Media.Exception(Exception: {0})", e)); return(Json(ErrorList.deleteVideo)); } } return(Json(1)); }
/** * Efface la vidéo dans la base de donnée et dans le fichier sur le serveur */ public JsonResult DeleteVideo(int idVideo, string poth = null) { Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("deleteVideo.Media.Entrée(idVideo: {0})", idVideo)); string videoPath = null; if (poth != null) { videoPath = null; } else { videoPath = Path.Combine(Server.MapPath(Tools.ConfigHelper._CST_DIRECTORY_VIDEO)); } var video = DALMedia.FindVideoById(idVideo); if (video != null) { try { videoPath = videoPath + video.nom + "." + video.format; DALMedia.DeleteVideo(video.Id); if (System.IO.File.Exists(videoPath)) { System.IO.File.Delete(videoPath); } Tools.Logger.Ecrire(Tools.Logger.Niveau.Info, string.Format("deleteVideo.Media.Sortie(videoPath: {0})", videoPath)); } catch (Exception e) { Tools.Logger.Ecrire(Tools.Logger.Niveau.Erreur, string.Format("deleteVideo.Media.Exception(Exception: {0})", e)); return(Json(ErrorList.deleteVideo)); } } return(Json(1)); }