예제 #1
0
        private async Task HandlePosts(LoginToken token, int?topicId, int postsPage)
        {
            if (topicId == null)
            {
                ShowPosts = false;
            }
            else
            {
                ShowPosts = true;
                var postResult = await Api.GetPostPageAsync(token.Id, topicId.Value, postsPage, PostPageSize);

                TotalNumberOfPosts = postResult.Count;
                Posts = postResult.Posts;

                PostPageLogic = new PageNumLogic("postsPage", postResult.CurrentPage, TotalNumberOfPosts, PostPageSize);
            }
        }
예제 #2
0
        private async Task HandleTopics(LoginToken token, int?topicId, int topicsPage)
        {
            if (topicId != null && topicId.Value != -1)
            {
                var topic = await Api.GetTopicAsync(token.Id, topicId.Value);

                if (topic == null)
                {
                    throw new Exception("Invalid topicId");
                }
                CanEditTopics = token.User.RawRole >= topic.RoleToEdit;
                CanEditPosts  = token.User.RawRole >= topic.RoleToEdit;
            }
            else
            {
                CanEditPosts = false;
            }

            var topicResult = await Api.GetTopicsPageAsync(token.Id, topicId, topicsPage, TopicPageSize);

            if (topicResult.ParentList == null || topicResult.ParentList.Count == 0)
            {
                _topicPath = null;
            }
            else
            {
                var current = topicResult.ParentList.Last();
                if (current.RoleToRead > token.User.RawRole)
                {
                    Response.Redirect("/Index");
                    return;
                }

                _topicPath = topicResult.ParentList;
            }

            _forumTopics = topicResult.Topics;

            TotalNumberOfTopics = topicResult.TopicCount;

            TopicPageLogic = new PageNumLogic("topicsPage", topicResult.CurrentPage, topicResult.TopicCount, TopicPageSize);
        }