Exemplo n.º 1
0
        public ActionResult AddReply(int itemid, string addreplycontent, string Captcha, string Prefix, ItemType idtype)
        {
            Post post;

            try
            {
                addreplycontent = _sanitizerService.Sanitize(addreplycontent);
                CheckPost(Captcha, Prefix, addreplycontent);
                switch (idtype)
                {
                case ItemType.Topic:
                    post = _blogUtil.AddTopicPost(itemid, User.Identity.Name, addreplycontent);
                    break;

                case ItemType.Blog:
                    post = _blogUtil.AddBlogPost(itemid, User.Identity.Name, addreplycontent);
                    break;

                default:
                    throw new BlogException("无效参数");
                }
                TriggerAddPost(post);
                HttpContext.Session.SetDateTime("LastPostTime", DateTime.Now);
            }
            catch (BlogException e)
            {
                return(Json(new { err = e.Message }));
            }
            string expmsg = HttpContext.Items["QuestMsg"] as string;

            return(Json(new { id = post.PostId, expmsg }));
        }