Ejemplo n.º 1
0
        public async Task <ActionResult> Delete(int id)
        {
            var notice = await NoticeService.GetByIdAsync(id) ?? throw new NotFoundException("公告已经被删除!");

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

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

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

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

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