Example #1
0
        /// <summary>
        /// 删除图片(逻辑删除,修改isDelete,移动图片路径)
        /// </summary>
        /// <param name="id">image</param>
        /// <returns></returns>
        public JsonResult DeleteImage(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(ResponseResult(1, "没有数据"));
            }
            Image image = imageApplication.FindById(id);

            if (image == null)
            {
                return(ResponseResult(2, "没有找到图片"));
            }
            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;
            }
            FileCommon.Move(path + image.IFileName, string.Format("{0}${1}-${2}-${3}", ConfigInfo.SourceSystemDelete, image.ImageId, image.IFileName, image.Type));
            //更新到数据库,改动了isDel
            imageApplication.Update(image);
            imageApplication.Commit();
            return(ResponseResult());
        }