Exemplo n.º 1
0
        private Result CloneCategoryDetails(int toSiteId, ICategory fromCate, int toCateId, bool includeExtend,
                                            bool includeTemplateBind)
        {
            var dto = CategoryDto.ConvertFrom(fromCate);

            dto.ID = 0;

            // 包含扩展
            if (!includeExtend)
            {
                dto.ExtendFields = new IExtendField[0];
            }
            else
            {
                dto.ExtendFields = new List <IExtendField>(fromCate.ExtendFields.Count);
                foreach (var extendField in fromCate.ExtendFields)
                {
                    var toField = GetCloneNewExtendField(toSiteId, extendField);
                    dto.ExtendFields.Add(toField);
                }
            }

            // 不包含模版
            if (!includeTemplateBind)
            {
                dto.CategoryTemplate        = null;
                dto.CategoryArchiveTemplate = null;
            }

            return(SaveCategory(toSiteId, toCateId, dto));
        }
Exemplo n.º 2
0
        public IEnumerable <CategoryDto> GetCategories(int siteId)
        {
            var site       = _repo.GetSiteById(siteId);
            var categories = site.Categories;

            foreach (var category in categories)
            {
                yield return(CategoryDto.ConvertFrom(category));
            }
        }
Exemplo n.º 3
0
        public CategoryDto GetCategory(int siteId, string catPath)
        {
            // 如果以"/"开头,则去掉
            if (!string.IsNullOrEmpty(catPath) && catPath[0] == '/')
            {
                catPath = catPath.Substring(1);
            }
            var site = _repo.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategoryByPath(catPath)));
        }
Exemplo n.º 4
0
        public IEnumerable <CategoryDto> GetCategories(
            int siteId, string catPath)
        {
            var site = repo.GetSiteById(siteId);
            var ic   = _categoryRep.GetCategoryByPath(siteId, catPath);

            if (ic == null)
            {
                yield break;
            }
            foreach (var category in ic.NextLevelChilds)
            {
                yield return(CategoryDto.ConvertFrom(category));
            }
        }
Exemplo n.º 5
0
        private IEnumerable <ArchiveDto> GetArchiveEnumertor(IEnumerable <IArchive> archives)
        {
            IDictionary <int, CategoryDto> categories = new Dictionary <int, CategoryDto>();
            ArchiveDto  archive;
            CategoryDto cateDto;
            int         categoryId;

            foreach (var ia in archives)
            {
                var av = ia.Get();
                archive = new ArchiveDto
                {
                    StrId       = av.StrId,
                    Id          = ia.GetAggregaterootId(),
                    PublisherId = av.AuthorId,
                    Alias       = av.Alias,
                    Agree       = av.Agree,
                    Disagree    = av.Disagree,
                    Content     = av.Content,
                    CreateTime  = TimeUtils.UnixTime(av.CreateTime),
                    Tags        = av.Tags,
                    UpdateTime  = TimeUtils.UnixTime(av.UpdateTime),
                    Source      = av.Source,
                    Thumbnail   = av.Thumbnail,
                    Title       = av.Title,
                    SmallTitle  = av.SmallTitle,
                    Location    = av.Location,
                    ViewCount   = av.ViewCount,
                    Outline     = av.Outline,
                    //TemplateBind=null,
                    ExtendValues = ia.GetExtendValues()
                };

                //archive = new ArchiveDto().CloneData(ia);
                //archive.ID = ia.ID;

                if (!categories.TryGetValue(categoryId = ia.Category.GetDomainId(), out cateDto))
                {
                    cateDto = CategoryDto.ConvertFrom(ia.Category);
                    categories.Add(categoryId, cateDto);
                }

                archive.Category = cateDto;
                yield return(archive);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="catPath"></param>
        /// <returns></returns>
        public IEnumerable <CategoryDto> GetCategories(int siteId, string catPath)
        {
            var       site = _repo.GetSiteById(siteId);
            ICategory ic   = catPath == "root" || String.IsNullOrEmpty(catPath)
                ? this._categoryRep.CreateCategory(new CmsCategoryEntity {
                SiteId = siteId, ParentId = 0
            })
                : this._categoryRep.GetCategoryByPath(siteId, catPath);

            if (ic == null)
            {
                yield break;
            }
            foreach (var category in ic.NextLevelChildren)
            {
                yield return(CategoryDto.ConvertFrom(category));
            }
        }
Exemplo n.º 7
0
        public CategoryDto GetCategoryByName(int siteId, string categoryName)
        {
            var site = _repo.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategoryByName(categoryName)));
        }
Exemplo n.º 8
0
        public CategoryDto GetCategory(int siteId, int categoryId)
        {
            var site = _repo.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategory(categoryId)));
        }