예제 #1
0
        public ActionResult GetUserOperationByPage()
        {
            bool state     = false;
            int  pageindex = Convert.ToInt32(Request["pageindex"]);
            int  userid    = Convert.ToInt32(Request["userid"]);
            int  pagecount;
            IList <UserOperation> list = UserOperationService.GetUserOperationByPage(userid, pageindex, out pagecount);
            ViewUserOperation     viewUserOperation = UserOperationService.GetUserOperationContent(list);

            return(Content(JsonString.GetString(viewUserOperation)));
        }
예제 #2
0
        public ViewUserOperation GetUserOperationContent(IList <UserOperation> lists)
        {
            if (null == lists)
            {
                throw new UserException("传入参数为空");
            }
            //---声明list 来保存来做的数据库操作,然后能够一次操作完成
            List <int> likePersonIds = new List <int>();
            List <int> likePostIds   = new List <int>();
            List <int> postIds       = new List <int>();
            List <int> commentIds    = new List <int>();

            foreach (UserOperation operation in lists)
            {
                switch (operation.Action)
                {
                case UserAction.LikePerson:
                    likePersonIds.Add(operation.EventId);
                    break;

                case UserAction.LikePost:
                    likePostIds.Add(operation.EventId);
                    break;

                case UserAction.Post:
                    //帖子的标题
                    postIds.Add(operation.EventId);
                    break;

                case UserAction.Comment:
                    commentIds.Add(operation.EventId);
                    break;

                default:
                    break;
                }
            }
            ViewUserOperation viewUserOperation = new ViewUserOperation();

            viewUserOperation.LikePersons = DbSession.LikePersonDal.GetLikedPersons(likePersonIds);
            viewUserOperation.LikePosts   = DbSession.LikePostDal.GetLikePosts(likePersonIds);
            viewUserOperation.Posts       = DbSession.PostDal.GetPosts(postIds);
            viewUserOperation.Comments    = DbSession.CommentDal.GetComments(commentIds);
            return(viewUserOperation);
        }