コード例 #1
0
ファイル: Article_InfoBusiness.cs プロジェクト: 908705107/src
        public async Task ProcessDataAsync(Article_Info data, List <PicDTO> bannerpic, List <string> CategoryList, List <string> TagList)
        {
            Data_FileBusiness filebll = new Data_FileBusiness();
            await Service.DeleteAsync <Article_ArticleCateGory>(x => x.ArtileID == data.Id); //删除文章分类表下包含该文章id的所有数据

            await Service.DeleteAsync <Article_TagArticle>(x => x.ArticleID == data.Id);     //删除标签分类表下包含该文章id的所有数据

            var aclist = CategoryList.Select(x => new Article_ArticleCateGory
            {
                Id         = IdHelper.GetId(),
                Deleted    = false,
                CategoryID = x,
                CreateTime = DateTime.Now,
                ArtileID   = data.Id
            }).ToList();
            var    tagdata = Service.GetIQueryable <Data_Tag>().Select(x => x.Id);
            string tagid;

            TagList.ForEach(x =>
            {
                var tamodel = new Article_TagArticle();
                tamodel.InitEntity();
                tamodel.ArticleID = data.Id;
                if (!tagdata.Any(t => t == x))//假如这个tag是tag表里没有的,就往tag表里新增
                {
                    var datatag = new Data_Tag();
                    datatag.InitEntity();
                    datatag.TagName  = x;
                    datatag.TabAlias = x;
                    Service.Insert <Data_Tag>(datatag);
                    tagid = datatag.Id;
                }
                else
                {
                    tagid = x;
                }
                tamodel.TagID = tagid;
                Service.Insert <Article_TagArticle>(tamodel);
            });
            //var atlist = TagList.Select(x => new Article_TagArticle
            //{
            //    Id = IdHelper.GetId(),
            //    Deleted = false,
            //    TagID = x,
            //    CreateTime = DateTime.Now,
            //    ArticleID = data.Id
            //}).ToList();
            await Service.InsertAsync <Article_ArticleCateGory>(aclist); //往文章分类表里插入数据

            var bannerid = filebll.AddBannerPic(data.Id, bannerpic);     //往图片表里插入导航图数据,并返回该导航图的id

            data.BannerPic = bannerid;
            if (!data.ReleaseTime.HasValue)
            {
                data.ReleaseTime = DateTime.Now;
            }
            data.LastModifiedTime = DateTime.Now;
        }
コード例 #2
0
        public async Task SaveData(Article_TagArticle data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                data.InitEntity();

                await _article_TagArticleBus.AddDataAsync(data);
            }
            else
            {
                await _article_TagArticleBus.UpdateDataAsync(data);
            }
        }