Esempio n. 1
0
        public ActionResult Reply(String id, FormCollection form)
        {
            ContestEntity    contest = ViewData["Contest"] as ContestEntity;
            ForumPostEntity  post    = ForumPostManager.GetForumPostByTopicID(id);
            ForumTopicEntity topic   = ForumTopicManager.GetForumTopic(post.TopicID);

            if (topic.Type != ForumTopicType.Contest || topic.RelativeID != contest.ContestID)
            {
                return(RedirectToErrorMessagePage("This contest does not have this topic!"));
            }

            ForumPostEntity reply = new ForumPostEntity()
            {
                Title   = form["title"],
                Content = form["content"]
            };

            String userip = this.GetCurrentUserIP();
            String link   = Url.Action("Topic", "Forum", new { area = "Contest", cid = contest.ContestID, id = post.TopicID });

            if (!ForumPostManager.InsertForumPost(reply, topic, post, userip, link))
            {
                return(RedirectToErrorMessagePage("Failed to post your reply!"));
            }

            return(RedirectToAction("Topic", "Forum", new { area = "Contest", cid = contest.ContestID, id = post.TopicID }));
        }
Esempio n. 2
0
        /// <summary>
        /// 讨论版主题页面
        /// </summary>
        /// <param name="id">主题ID</param>
        /// <returns>操作后的结果</returns>
        public ActionResult Topic(Int32 id = -1)
        {
            ContestEntity    contest = ViewData["Contest"] as ContestEntity;
            ForumPostEntity  post    = ForumPostManager.GetForumPostByTopicID(id.ToString());
            ForumTopicEntity topic   = ForumTopicManager.GetForumTopic(post.TopicID);

            if (topic.Type != ForumTopicType.Contest || topic.RelativeID != contest.ContestID)
            {
                return(RedirectToErrorMessagePage("This contest does not have this topic!"));
            }

            List <ForumPostEntity> list = ForumPostManager.GetForumPostList(topic, false);

            return(View(new Tuple <ForumTopicEntity, List <ForumPostEntity> >(topic, list)));
        }
Esempio n. 3
0
        /// <summary>
        /// 讨论版回复页面
        /// </summary>
        /// <param name="id">帖子ID</param>
        /// <param name="tid">主题ID</param>
        /// <returns>操作后的结果</returns>
        public ActionResult Reply(Int32 id = -1, String tid = "")
        {
            ForumPostEntity  post  = (String.IsNullOrEmpty(tid) ? ForumPostManager.GetForumPost(id) : ForumPostManager.GetForumPostByTopicID(tid));
            ForumTopicEntity topic = ForumTopicManager.GetForumTopic(post.TopicID);

            if (topic.Type == ForumTopicType.Contest)
            {
                return(RedirectToErrorMessagePage("This topic is not in the main disscus board!"));
            }

            post.RelativeType = (topic.Type == ForumTopicType.Problem ? topic.Type : ForumTopicType.Default);
            post.RelativeID   = (topic.Type == ForumTopicType.Problem ? topic.RelativeID : -1);

            List <TreeNode <ForumPostEntity> > listTreeNode = ForumPostManager.GetPostTreeList(topic, post.PostID);

            ViewBag.IsLocked = topic.IsLocked;

            return(View(new Tuple <ForumPostEntity, List <TreeNode <ForumPostEntity> > >(post, listTreeNode)));
        }