Пример #1
0
        public ManageCommentsList GetManageComments(int page, int rows, string UserAccount, string UserName)       //评论列表数据
        {
            List <ManageComment>         CommentsList  = new List <ManageComment>();
            List <BlogModel.BlogComment> trans         = new List <BlogComment>();
            List <BlogModel.BlogUser>    tempUsersList = repository.GetUsersAll();
            var totalComment = repository.GetCommentsAll().Count();

            if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(UserAccount))//如果过Account和Name都存在
            {
                trans = repository.GetCommentByAccountAndName(UserAccount, UserName);
            }
            if (!string.IsNullOrEmpty(UserAccount) && string.IsNullOrEmpty(UserName))//如果Account存在,就直接查询
            {
                trans = repository.GetCommentByAccount(UserAccount);
            }
            if (!string.IsNullOrEmpty(UserName) && string.IsNullOrEmpty(UserAccount))//如果Name存在就搜索Name,昵称Name是模糊搜索
            {
                trans = repository.GetCommentByName(UserName);
            }
            if (string.IsNullOrEmpty(UserName) && string.IsNullOrEmpty(UserAccount))//如果都为空,则默认
            {
                trans = repository.GetCommentsAll();
            }
            if (trans == null)
            {
                return(null);
            }
            for (int i = (page - 1) * rows; i < page * rows; i++)
            {
                if (i >= trans.Count())
                {
                    break;
                }
                ManageComment temp = new ManageComment
                {
                    Account = trans[i].Account,
                    Id      = trans[i].CommmentID,
                    Name    = tempUsersList.Find(c => c.Account == trans[i].Account).Name,
                    TextId  = trans[i].TextID,
                    Content = trans[i].CommentText,
                    Date    = trans[i].CommentChangeDate.ToString()
                };
                CommentsList.Add(temp);
            }
            ManageCommentsList templist = new ManageCommentsList {
                CommentNumber = trans.Count(), TempCommentsLists = CommentsList
            };

            return(templist);
        }
Пример #2
0
        public void Delete(int id)
        {
            ManageComment comment = new ManageComment();

            comment.deleteComment(id);
        }
Пример #3
0
        public void Put(int id, [FromBody] Comment value)
        {
            ManageComment comment = new ManageComment();

            comment.UpdateComment(value, id);
        }
Пример #4
0
        public void Post([FromBody] Comment value)
        {
            ManageComment comment = new ManageComment();

            comment.CreateComment(value);
        }
Пример #5
0
        public Comment Get(int id)
        {
            ManageComment comment = new ManageComment();

            return(comment.GetCommentFromId(id));
        }
Пример #6
0
        public IEnumerable <Comment> GetCommentsForTask(int id)
        {
            ManageComment comment = new ManageComment();

            return(comment.GetCommentsForTask(id));
        }
Пример #7
0
        public IEnumerable <Comment> Get()
        {
            ManageComment comment = new ManageComment();

            return(comment.getAllComments());
        }