示例#1
0
        public async Task <ActionResult> Delete(int id)
        {
            var post = await MiscService.GetByIdAsync(id) ?? throw new NotFoundException("杂项页已被删除!");

            var srcs = post.Content.MatchImgSrcs().Where(s => s.StartsWith("/"));

            foreach (var path in srcs)
            {
                try
                {
                    System.IO.File.Delete(Path.Combine(HostEnvironment.WebRootPath + path));
                }
                catch (IOException)
                {
                }
            }

            bool b = await MiscService.DeleteByIdSavedAsync(id) > 0;

            return(ResultData(null, b, b ? "删除成功" : "删除失败"));
        }
示例#2
0
        public async Task <ActionResult> Delete(int id)
        {
            bool b = await MiscService.DeleteByIdSavedAsync(id) > 0;

            return(ResultData(null, b, b ? "删除成功" : "删除失败"));
        }