Пример #1
0
        protected override async Task OnParametersSetAsync()
        {
            var node = await NodeService.GetAsync(Id);

            Post         = Models.Post.Create(node);
            PostUserName = !string.IsNullOrEmpty(node.CreatedBy) ? await UserService.GetUserNameAsync(node.CreatedBy) : string.Empty;

            Comments = new CommentsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module   = Constants.ForumsModule,
                    Type     = Constants.CommentType,
                    ParentId = Post.Id,
                    OrderBy  = new string[]
                    {
                        OrderBy.Hot,
                        OrderBy.Latest
                    }
                }
            };
            await Comments.InitAsync();

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

            CanEditPost = await SecurityService.AllowedAsync(
                loggedInUserId,
                Post.CreatedBy,
                Constants.ForumsModule,
                Constants.PostType,
                Actions.Edit
                );

            CanDeletePost = await SecurityService.AllowedAsync(
                loggedInUserId,
                Post.CreatedBy,
                Constants.ForumsModule,
                Constants.PostType,
                Actions.Delete
                );

            CanAddComment = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.CommentType,
                Actions.Add
                );

            CanVote = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.ForumsModule,
                Constants.PostType,
                Actions.Vote
                );
        }