Exemple #1
0
        public void GoToForum()
        {
            BoardForum    forum    = _boardForumRepository.GetForumByGroupID(_webContext.GroupID);
            BoardCategory category = _boardCategoryRepository.GetCategoryByCategoryID(forum.CategoryID);

            _redirector.GoToForumsForumView(forum.PageName, category.PageName);
        }
Exemple #2
0
        public void GoToForum(string ForumPageName)
        {
            BoardForum    forum    = _forumRepository.GetForumByPageName(ForumPageName);
            BoardCategory category = _categoryRepository.GetCategoryByCategoryID(forum.CategoryID);

            _redirector.GoToForumsForumView(forum.PageName, category.PageName);
        }
Exemple #3
0
        public void Save(BoardPost post)
        {
            //is new thread
            if (_webContext.LoggedIn)
            {
                post.ReplyByAccountID = _webContext.AccountID;
                post.ReplyByUsername  = _webContext.CurrentUser.UserName;
                if (_webContext.PostID > 0)
                {
                    BoardPost postToReplyToo = _postRepository.GetPostByID(_webContext.PostID);
                    if (postToReplyToo.IsThread)
                    {
                        post.ThreadID = postToReplyToo.PostID;
                    }
                    else
                    {
                        //if post.ThreadID = postToReplyToo.ThreadID thì ở thread show tất cả bình luận.
                        post.ThreadID = postToReplyToo.PostID;
                    }
                    post.ForumID = postToReplyToo.ForumID;
                }
                else
                if (_webContext.ForumID > 0)
                {
                    post.ForumID  = _webContext.ForumID;
                    post.IsThread = _webContext.IsThread;
                    if (!_postRepository.CheckPostPageNameIsUnique(post.PageName))
                    {
                        _view.SetErrorMessage("The page name you are trying to use is already in use!");
                        return;
                    }
                }
                post.CreateDate = DateTime.Now;
                post.UpdateDate = DateTime.Now;
                post.AccountID  = _webContext.CurrentUser.AccountID;
                post.Username   = _webContext.CurrentUser.UserName;
                post.ReplyCount = 0;
                post.ViewCount  = 0;
                if (post.PageName != null)
                {
                    post.PageName = post.PageName.Replace(" ", "-");
                }
                else
                {
                    post.PageName = post.Name;
                    post.PageName = post.PageName.Replace(" ", "-");
                }

                post.PostID = _postRepository.SavePost(post);

                BoardForum forum = _forumRepository.GetForumByID(post.ForumID);
                forum.LastPostByAccountID = post.AccountID;
                forum.LastPostByUsername  = post.Username;
                _forumRepository.SaveForum(forum);
                BoardCategory category = _categoryRepository.GetCategoryByCategoryID(forum.CategoryID);
                category.LastPostByAccountID = post.AccountID;
                category.LastPostByUsername  = post.Username;
                _categoryRepository.SaveCategory(category);
                BoardPost thread;
                if (post.IsThread)
                {
                    thread = _postRepository.GetPostByID(post.PostID);
                }
                else
                {
                    thread = _postRepository.GetPostByID((long)post.ThreadID);
                }

                //is this forum part of a group?
                Group group = _groupRepository.GetGroupByForumID(forum.ForumID);

                //add an alert to the filter
                if (post.IsThread)
                {
                    //is this a group forum?
                    if (group != null)
                    {
                        _alertService.AddNewBoardThreadAlert(category, forum, thread, group);
                    }
                    else
                    {
                        _alertService.AddNewBoardThreadAlert(category, forum, thread);
                    }
                }
                else
                {
                    //is this a group forum?
                    if (group != null)
                    {
                        _alertService.AddNewBoardPostAlert(category, forum, post, thread, group);
                    }
                    else
                    {
                        _alertService.AddNewBoardPostAlert(category, forum, post, thread);
                    }
                }
                //_redirector.GoToForumsViewPost(forum.PageName, category.PageName, thread.PageName);
                if (_webContext.IsThread == false)
                {
                    _redirector.Redirect("~/Groups/ViewGroupForumPost.aspx?PostID=" + _webContext.PostID + "&GroupID=" + _webContext.GroupID);
                }
                else
                {
                    _redirector.Redirect("~/Groups/ViewGroup.aspx?GroupID=" + _webContext.GroupID);
                }
            }
            else
            {
                _redirector.GoToAccountLoginPage();
            }
        }