Example #1
0
        /// <summary>
        ///  删除数据
        /// </summary>
        /// Author  :Napoleon
        /// Created :2015-06-06 02:02:20
        public int DeleteNewsContents(string ids)
        {
            int i;

            try
            {
                List <NewsContents> contents      = _newscontentsDao.GetNewsContentsByIds(ids);            //查询新闻内容集合
                string uploadIds                  = GetNewsByList(contents);                               //组装上传文件Id
                List <NewsUploadFile> uploadFiles = _newsUploadFileDao.GetNewsUploadFilesByIds(uploadIds); //查询上传文件集合
                _newscontentsDao.DeleteNewsContents(ids);                                                  //删除新闻内容
                _newsUploadFileDao.DeleteNewsUploadFile(uploadIds);                                        //删除上传文件内容
                //删除上传文件
                foreach (NewsUploadFile file in uploadFiles)
                {
                    if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(file.FileUrl)))
                    {
                        System.IO.File.Delete(HttpContext.Current.Server.MapPath(file.FileUrl));
                    }
                }
                i = 1;
            }
            catch (Exception)
            {
                i = -1;
            }
            return(i);
        }
 /// <summary>
 ///  删除数据
 /// </summary>
 /// Author  :Napoleon
 /// Created :2015-06-06 02:02:28
 public int DeleteNewsUploadFile(string id)
 {
     return(_newsuploadfileDao.DeleteNewsUploadFile(id));
 }