コード例 #1
0
ファイル: Index.cshtml.cs プロジェクト: atsmith6/SGForum
        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
ファイル: Index.cshtml.cs プロジェクト: atsmith6/SGForum
        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);
        }