/// <summary> /// 删除图片(物理删除) /// </summary> /// <param name="id">image</param> /// <returns></returns> public JsonResult RealDeleteFile(string fileName) { if (string.IsNullOrWhiteSpace(fileName)) { return(ResponseResult(1, "没有数据")); } FileCommon.Remove(Server.MapPath(ConfigInfo.SourceMusicPath + fileName)); return(ResponseResult()); }
/// <summary> /// 删除图片(物理删除) /// </summary> /// <param name="id">image</param> /// <returns></returns> public JsonResult RealDeleteImage(string id) { if (string.IsNullOrWhiteSpace(id)) { return(ResponseResult(1, "没有数据")); } Image image = imageApplication.FindById(id); if (image == null) { return(ResponseResult(2, "没有找到图片")); } if (image.ReferenceCount > 0) { return(ResponseResult(3, "图片被引用,无法删除")); } image.IsDel = 1; string path = string.Empty; switch (image.Type) { case ImageType.Blog: path = ConfigInfo.SourceBlogPath; break; case ImageType.Said: path = ConfigInfo.SourceSaidPath; break; case ImageType.System: case ImageType.Icon: case ImageType.Page: case ImageType.Lab: case ImageType.Other: default: path = ConfigInfo.SourceSystemPath; break; } imageApplication.Delete(image); if (imageApplication.Commit()) { FileCommon.Remove(Server.MapPath(path + image.IFileName)); return(ResponseResult()); } else { return(ResponseResult(2, "删除图片异常")); } }
/// <summary> /// 删除图片(物理删除) /// </summary> /// <param name="id">image</param> /// <returns></returns> public JsonResult RealDeleteMusic(string id) { if (string.IsNullOrWhiteSpace(id)) { return(ResponseResult(1, "没有数据")); } Song model = songApplication.FindById(id); if (model == null) { return(ResponseResult(2, "没有找到音乐对象")); } if (model.ReferenceCount > 0) { return(ResponseResult(3, "歌曲被引用,无法删除")); } FileCommon.Remove(Server.MapPath(ConfigInfo.SourceMusicPath + model.SongFileName)); imageApplication.MinusReferenceCount(model.ImageId); songApplication.Delete(model); return(songApplication.Commit() ? ResponseResult() : ResponseResult(2, "删除失败")); }