コード例 #1
0
        protected override async Task OnParametersSetAsync()
        {
            Categories = (await CategoryService.GetAllAsync(Constants.ArticlesModule))
                         .OrderBy(a => a.Weight)
                         .ThenBy(a => a.Name);

            foreach (var category in Categories)
            {
                var articles = new ArticlesModel(NodeService)
                {
                    NodeSearch = new NodeSearch()
                    {
                        Module     = Constants.ArticlesModule,
                        Type       = Constants.ArticleType,
                        CategoryId = category.Id,
                        OrderBy    = new string[]
                        {
                            OrderBy.Weight,
                            OrderBy.Latest,
                            OrderBy.Title
                        },
                        PageSize = 9
                    }
                };
                await articles.InitAsync();

                Articles.Add(category.Id, articles);
            }

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanAddCategory = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.CategoryType,
                Actions.Add
                );
        }
コード例 #2
0
        protected override async Task OnParametersSetAsync()
        {
            Category = await CategoryService.GetBySlugAsync(Slug, Constants.ArticlesModule);

            Articles = new ArticlesModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module     = Constants.ArticlesModule,
                    Type       = Constants.ArticleType,
                    CategoryId = Category.Id,
                    OrderBy    = new string[]
                    {
                        OrderBy.Weight,
                        OrderBy.Latest,
                        OrderBy.Title
                    }
                }
            };
            await Articles.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanEditCategory = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.CategoryType,
                Actions.Add
                );

            CanAddArticle = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.ArticleType,
                Actions.Add
                );
        }
コード例 #3
0
ファイル: Index.razor.cs プロジェクト: hasanhadid/BlazorWorld
        protected override async Task OnParametersSetAsync()
        {
            var configSearch = new NodeSearch()
            {
                Module = Constants.ArticlesModule,
                Type   = Constants.ConfigType
            };
            var configNodes = (await NodeService.GetAsync(configSearch, 0));

            if (configNodes.Length > 0)
            {
                Config = configNodes[0];
            }
            var nodeSearch = new NodeSearch()
            {
                Module   = Constants.ArticlesModule,
                Type     = Constants.CategoryType,
                OrderBy  = $"{OrderBy.Weight},{OrderBy.Title}",
                RootOnly = true
            };
            var nodes = (await NodeService.GetAsync(nodeSearch, 0));

            Categories = nodes.ConvertTo <Models.Category>();

            foreach (var category in Categories)
            {
                var articles = new ArticlesModel(NodeService)
                {
                    NodeSearch = new NodeSearch()
                    {
                        Module          = Constants.ArticlesModule,
                        Type            = Constants.ArticleType,
                        ParentId        = category.Id,
                        OrderBy         = $"{OrderBy.Weight},{OrderBy.Latest},{OrderBy.Title}",
                        PageSize        = 9,
                        TruncateContent = 140
                    }
                };
                await articles.InitAsync();

                Articles.Add(category.Id, articles);
            }

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanEditConfig = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.ConfigType,
                Actions.Edit
                );

            CanAddCategory = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.CategoryType,
                Actions.Add
                );
        }
コード例 #4
0
        protected override async Task OnParametersSetAsync()
        {
            var node = await NodeService.GetBySlugAsync(
                Constants.ArticlesModule,
                Constants.CategoryType,
                Slug);

            Category = Models.Category.Create(node);

            if (!string.IsNullOrEmpty(Category.ParentId))
            {
                var parentNode = await NodeService.GetAsync(Category.ParentId);

                if (parentNode != null)
                {
                    ParentCategory = Models.Category.Create(parentNode);
                }
            }

            var nodeSearch = new NodeSearch()
            {
                Module   = Constants.ArticlesModule,
                Type     = Constants.CategoryType,
                ParentId = Category.Id,
                OrderBy  = $"{OrderBy.Weight},{OrderBy.Title}"
            };
            var nodes = await NodeService.GetAsync(nodeSearch, 0);

            Categories = nodes.ConvertTo <Models.Category>();

            Articles = new ArticlesModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module          = Constants.ArticlesModule,
                    Type            = Constants.ArticleType,
                    ParentId        = Category.Id,
                    OrderBy         = $"{OrderBy.Weight},{OrderBy.Latest},{OrderBy.Title}",
                    TruncateContent = 140
                }
            };
            await Articles.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanAddCategory = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.CategoryType,
                Actions.Add
                );

            CanEditCategory = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.CategoryType,
                Actions.Add
                );

            CanDeleteCategory = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.CategoryType,
                Actions.Delete
                );

            CanAddArticle = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ArticlesModule,
                Constants.ArticleType,
                Actions.Add
                );
        }