GetContentCategoryMapByContentID() static private method

static private GetContentCategoryMapByContentID ( CarrotCMSDataContext ctx, Guid rootContentID ) : IQueryable
ctx CarrotCMSDataContext
rootContentID Guid
return IQueryable
Ejemplo n.º 1
0
        private void SaveKeywordsAndTags(CarrotCMSDataContext _db)
        {
            IQueryable <carrot_TagContentMapping>      oldContentTags       = CannedQueries.GetContentTagMapByContentID(_db, this.Root_ContentID);
            IQueryable <carrot_CategoryContentMapping> oldContentCategories = CannedQueries.GetContentCategoryMapByContentID(_db, this.Root_ContentID);

            if (this.ContentType == ContentPageType.PageType.BlogEntry)
            {
                List <carrot_TagContentMapping> newContentTags = (from x in this.ContentTags
                                                                  select new carrot_TagContentMapping {
                    ContentTagID = x.ContentTagID,
                    Root_ContentID = this.Root_ContentID,
                    TagContentMappingID = Guid.NewGuid()
                }).ToList();

                List <carrot_CategoryContentMapping> newContentCategories = (from x in this.ContentCategories
                                                                             select new carrot_CategoryContentMapping {
                    ContentCategoryID = x.ContentCategoryID,
                    Root_ContentID = this.Root_ContentID,
                    CategoryContentMappingID = Guid.NewGuid()
                }).ToList();

                foreach (carrot_TagContentMapping s in newContentTags)
                {
                    _db.carrot_TagContentMappings.InsertOnSubmit(s);
                }
                foreach (carrot_CategoryContentMapping s in newContentCategories)
                {
                    _db.carrot_CategoryContentMappings.InsertOnSubmit(s);
                }
            }

            _db.carrot_TagContentMappings.BatchDelete(oldContentTags);
            _db.carrot_CategoryContentMappings.BatchDelete(oldContentCategories);
        }