Ejemplo n.º 1
0
        /// <summary>
        /// 保存上传记录,其中info.Id不能为空
        /// </summary>
        /// <param name="info"></param>
        public Base_CatalogArticle SaveCatalogArticleInfo(ResourceFileInfo info)
        {
            if (info.Id == 0)
            {
                return(null);
            }

            var a = _article.GetById(info.Id);

            //当上传的目录Id为0时表示上传到默认(根目录)
            if (info.CatalogId == 0)
            {
                info.CatalogId = GetUserRootCatalog(a.Article.EditorId).Id;
            }

            //判断是否在相同的文件夹上传重复的文件
            if (_article.GetAllQuery().Where(art => art.ArticleId == a.ArticleId).Select(cat => cat.CatalogId).Contains(info.CatalogId))
            {
                int id = _article.GetAllQuery().FirstOrDefault(art => art.ArticleId == a.ArticleId && art.CatalogId == info.CatalogId).Id;
                _article.Delete(id);
            }

            Base_CatalogArticle ua = new Base_CatalogArticle
            {
                Article    = a.Article,
                ArticleId  = a.ArticleId,
                CatalogId  = info.CatalogId,
                CreateTime = DateTime.Now
            };

            _article.Save(ua);
            return(ua);
        }