예제 #1
0
        protected override async Task OnParametersSetAsync()
        {
            var topicNode = await NodeService.GetAsync(Id);

            Topic         = Models.Topic.Create(topicNode);
            TopicUserName = !string.IsNullOrEmpty(topicNode.CreatedBy) ? await UserService.GetUserNameAsync(topicNode.CreatedBy) : string.Empty;

            var forumNode = await NodeService.GetAsync(Topic.ForumId);

            Forum = Models.Forum.Create(forumNode);
            Posts = new PostsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module   = Constants.ForumsModule,
                    Type     = Constants.PostType,
                    ParentId = Topic.Id,
                    OrderBy  = new string[]
                    {
                        OrderBy.Hot,
                        OrderBy.Latest
                    }
                }
            };
            await Posts.InitAsync();

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

            CanEditTopic = await SecurityService.AllowedAsync(
                loggedInUserId,
                Topic.CreatedBy,
                Constants.ForumsModule,
                Constants.TopicType,
                Actions.Edit
                );

            CanDeleteTopic = await SecurityService.AllowedAsync(
                loggedInUserId,
                Topic.CreatedBy,
                Constants.ForumsModule,
                Constants.TopicType,
                Actions.Delete
                );

            CanAddPost = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.PostType,
                Actions.Add
                );

            CanVote = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.TopicType,
                Actions.Vote
                );
        }
예제 #2
0
        protected override async Task OnParametersSetAsync()
        {
            var blog = await NodeService.GetBySlugAsync(
                Constants.BlogsModule,
                Constants.BlogType,
                Slug);

            Blog  = Models.Blog.Create(blog);
            Posts = new PostsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module          = Constants.BlogsModule,
                    Type            = Constants.PostType,
                    ParentId        = Blog.Id,
                    OrderBy         = $"{OrderBy.Weight},{OrderBy.Latest},{OrderBy.Title}",
                    TruncateContent = 140
                }
            };
            await Posts.InitAsync();

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

            CanEditBlog = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.BlogsModule,
                Constants.BlogType,
                Actions.Add
                );

            CanDeleteBlog = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.BlogsModule,
                Constants.BlogType,
                Actions.Delete
                );

            CanAddPost = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.BlogsModule,
                Constants.PostType,
                Actions.Add
                );
        }