コード例 #1
0
        /// <summary>
        /// 保存用户评论数据
        /// </summary>
        /// <param name="context"></param>
        public void SaveUserPosts(HttpContext context)
        {
            ZwJson zwJson = new ZwJson();
            UserPostsService userPostsService = new UserPostsService(_session);
            UserService userService = new UserService(_session);

            var postid = context.Request.Params["postid"];
            var khtml = context.Request.Params["khtml"];
            var name = context.Session["UserName"];

            if (name != null)
            {
                var data = userService.FindByName(name.ToString());
                Posts posts = new Posts() { Id = postid };
                UserPosts userPosts = new UserPosts()
                {
                    Id = Guid.NewGuid().ToString(),
                    Contents = khtml,
                    CreateDt = DateTime.Now,
                    Posts = posts,
                    User = data[0]
                };
                userPostsService.Save(userPosts);
                zwJson.IsSuccess = true;
                zwJson.JsExecuteMethod = "ajax_SaveUserPosts";
            }
            else
            {
                zwJson.IsSuccess = false;
                zwJson.Msg = "请先登录!";
            }
            context.Response.Write(_jss.Serialize(zwJson));
        }
コード例 #2
0
        public void GetUserPostsById(HttpContext context)
        {
            ZwJson zwJson = new ZwJson();
            PostsService postsService = new PostsService(_session);
            UserPostsService userPostsService = new UserPostsService(_session);
            var postid = context.Request.Params["postid"];
            var list2 = postsService.FindById2(postid);

            list2.ReplyCount = list2.UserPostses.Count;
            zwJson.Other = list2.ReplyCount.ToString();
            postsService.SaveOrUpdate(list2);

            Posts posts = new Posts() { Id = postid };
            var list = userPostsService.FindById(posts);
            zwJson.IsSuccess = true;
            zwJson.Data = list;
            zwJson.JsExecuteMethod = "ajax_GetUserPostsById";
            context.Response.Write(_jss.Serialize(zwJson));
        }