Esempio n. 1
0
        private Result CloneCategoryDetails(int toSiteId, ICategory fromCate, int toCateId, bool includeExtend, bool includeTemplateBind)
        {
            CategoryDto 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(this.SaveCategory(toSiteId, toCateId, dto));
        }
Esempio n. 2
0
        public async Task <IActionResult> Get(long id)
        {
            var categoryDto = await _categoryService.ReadAsync(id);

            var result = CategoryDto.ConvertFrom(categoryDto);

            return(new ObjectResult(result));
        }
Esempio n. 3
0
        public CategoryDto GetParentCategory(int siteId, int lft)
        {
            ICategory category = this._resp.GetSiteById(siteId).GetCategoryByLft(lft);

            if (category == null || category.Parent == null)
            {
                return(default(CategoryDto));
            }
            return(CategoryDto.ConvertFrom(category.Parent));
        }
Esempio n. 4
0
        public IEnumerable <CategoryDto> GetCategories(int siteId)
        {
            ISite             site       = this.repo.GetSiteById(siteId);
            IList <ICategory> categories = site.Categories;

            foreach (ICategory category in categories)
            {
                yield return(CategoryDto.ConvertFrom(category));
            }
        }
Esempio n. 5
0
        public CategoryDto GetCategory(int siteId, string catPath)
        {
            // 如果以"/"开头,则去掉
            if (!String.IsNullOrEmpty(catPath) && catPath[0] == '/')
            {
                catPath = catPath.Substring(1);
            }
            ISite site = this.repo.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategoryByPath(catPath)));
        }
Esempio n. 6
0
        public IEnumerable <CategoryDto> GetCategories(
            int siteId, int lft, int rgt,
            CategoryContainerOption categoryContainerOption)
        {
            ISite site = this._resp.GetSiteById(siteId);
            IEnumerable <ICategory> categories =
                site.GetCategories(lft, rgt, categoryContainerOption);
            CategoryDto dto;

            foreach (ICategory category in categories)
            {
                yield return(CategoryDto.ConvertFrom(category));
            }
        }
Esempio n. 7
0
        public IEnumerable <CategoryDto> GetCategories(
            int siteId, String catPath)
        {
            ISite     site = this.repo.GetSiteById(siteId);
            ICategory ic   = this._categoryRep.GetCategoryByPath(siteId, catPath);

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

            foreach (IArchive ia in archives)
            {
                archive = new ArchiveDto
                {
                    StrId      = ia.StrId,
                    Id         = ia.Id,
                    Author     = ia.Author,
                    Alias      = ia.Alias,
                    Agree      = ia.Agree,
                    Disagree   = ia.Disagree,
                    Content    = ia.Content,
                    CreateDate = ia.CreateDate,
                    // FirstImageUrl=ia.FirstImageUrl,
                    Flags          = ia.Flags,
                    Tags           = ia.Tags,
                    LastModifyDate = ia.LastModifyDate,
                    Source         = ia.Source,
                    Thumbnail      = ia.Thumbnail,
                    Title          = ia.Title,
                    SmallTitle     = ia.SmallTitle,
                    Location       = ia.Location,
                    ViewCount      = ia.ViewCount,
                    Outline        = ia.Outline,
                    //TemplateBind=null,
                    ExtendValues = ia.ExtendValues
                };

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

                if (!categories.TryGetValue(categoryId = ia.Category.Id, out cateDto))
                {
                    cateDto = CategoryDto.ConvertFrom(ia.Category);
                    categories.Add(categoryId, cateDto);
                }
                archive.Category = cateDto;
                yield return(archive);
            }
        }
Esempio n. 9
0
        private IEnumerable <ArchiveDto> GetArchiveEnumertor(IEnumerable <IArchive> archives)
        {
            IDictionary <int, CategoryDto> categories = new Dictionary <int, CategoryDto>();
            ArchiveDto  archive;
            CategoryDto cateDto;
            int         categoryId;

            foreach (IArchive ia in archives)
            {
                CmsArchiveEntity 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),
                    Flags       = av.Flags,
                    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);
            }
        }
Esempio n. 10
0
        public void Data1_POST()
        {
            IList <CategoryDto> categories = new List <CategoryDto>();

            //根节点
            ServiceCall.Instance.SiteService.HandleCategoryTree(SiteId, 1, (c, level, isLast) =>
            {
                var dto = CategoryDto.ConvertFrom(c);


                dto.Name = "<span class=\"level" + level.ToString() + "\">"
                           + dto.Name
                           + "</span>";

                categories.Add(dto);
            });

            PagerJson(categories, $"共{categories.Count.ToString()}条");
        }
Esempio n. 11
0
        public void Data_POST()
        {
            IList <CategoryDto> categories = new List <CategoryDto>();

            //根节点
            ServiceCall.Instance.SiteService.HandleCategoryTree(this.SiteId, 1, (c, level, isLast) =>
            {
                CategoryDto dto = CategoryDto.ConvertFrom(c);


                dto.Name = "<span class=\"level" + level.ToString() + "\">"
                           + dto.Name
                           + "</span>";

                categories.Add(dto);
            });

            base.PagerJson(categories, String.Format("共{0}条", categories.Count.ToString()));
        }
Esempio n. 12
0
        public CategoryDto GetCategoryByLft(int siteId, int lft)
        {
            ISite site = this._resp.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategoryByLft(lft)));
        }
Esempio n. 13
0
        public CategoryDto GetCategory(int siteId, string categoryTag)
        {
            ISite site = this._resp.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategoryByTag(categoryTag)));
        }
Esempio n. 14
0
        public CategoryDto GetCategory(int siteId, int categoryId)
        {
            ISite site = this._resp.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategory(categoryId)));
        }
Esempio n. 15
0
        public CategoryDto GetCategory(int siteId, string catPath)
        {
            ISite site = this.repo.GetSiteById(siteId);

            return(CategoryDto.ConvertFrom(site.GetCategoryByPath(catPath)));
        }
Esempio n. 16
0
        public async Task <IEnumerable <CategoryDto> > Get()
        {
            var categories = await _categoryService.ReadAllAsync();

            return(categories.Select(category => CategoryDto.ConvertFrom(category)).ToList());
        }