Пример #1
0
        public string getPetitionList(string post)
        {
            SelectPetitionPostData    postData           = post.FromJsonTo <SelectPetitionPostData>();
            List <ReturnPetitionList> returnPetitionList = new List <ReturnPetitionList>();

            PageMoudle petitionPageModle = this.Lazy_PetitionBLL.getPetitionList(postData.pageSize, new List <SortField>()
            {
                new SortField()
                {
                    FieldName = "handsUpCount", DESC = true
                },
                new SortField()
                {
                    FieldName = "id", DESC = false
                },
            }, postData.reviewStatus);

            petitionPageModle.CurrentPage = postData.currentPage;

            List <PetitionList> petitionList = petitionPageModle.CurrentData.ToList <PetitionList>();

            returnPetitionList = petitionList.GroupBy(
                p => p.Id,
                (key, g) => {
                PetitionList p = petitionList.FirstOrDefault <PetitionList>(item => item.Id == key);
                return(new ReturnPetitionList()
                {
                    Id = p.Id,
                    Title = p.Title,
                    Description = p.Description,
                    CreateTime = p.CreateTime,
                    FromUserId = p.FromUserId,
                    ToUserId = p.ToUserId,
                    ToUserName = p.ToUserName,
                    Status = p.Status,
                    ReviewStatus = p.ReviewStatus,
                    HandsUp = p.HandsUp,
                    HandsUpCount = p.HandsUpCount,
                    Pics = g.ToList().Where <PetitionList>(item => item.ImageUrl != null).Select <PetitionList, string>(item => item.ImageUrl).ToList <string>(),
                    FromUserName = p.FromUserName,
                    FromUserAvatar = p.FromUserAvatar
                });
            }
                ).ToList <ReturnPetitionList>();
            return(new ResultWithPage()
            {
                Code = 0,
                Data = returnPetitionList,
                CurrentPage = petitionPageModle.CurrentPage,
                PageCount = petitionPageModle.PageCount,
                Total = petitionPageModle.TotalCount,
            }.ToJSON());
        }
Пример #2
0
        public string getPetitionById(string post)
        {
            SelectPetitionPostData postData = post.FromJsonTo <SelectPetitionPostData>();


            List <ReturnPetitionList> returnPetitionList = new List <ReturnPetitionList>();
            List <PetitionList>       petitionList       = this.Lazy_PetitionBLL.getPetitionById(postData.petitionId).ToList <PetitionList>();

            returnPetitionList = petitionList.GroupBy(
                p => p.Id,
                (key, g) => {
                PetitionList p = petitionList.FirstOrDefault <PetitionList>(item => item.Id == key);
                return(new ReturnPetitionList()
                {
                    Id = p.Id,
                    Title = p.Title,
                    Description = p.Description,
                    CreateTime = p.CreateTime,
                    FromUserId = p.FromUserId,
                    ToUserId = p.ToUserId,
                    ToUserName = p.ToUserName,
                    Status = p.Status,
                    ReviewStatus = p.ReviewStatus,
                    HandsUp = p.HandsUp,
                    HandsUpCount = p.HandsUpCount,
                    Pics = g.ToList().Where <PetitionList>(item => item.ImageUrl != null).Select <PetitionList, string>(item => item.ImageUrl).ToList <string>(),
                    FromUserName = p.FromUserName,
                    FromUserAvatar = p.FromUserAvatar
                });
            }
                ).ToList <ReturnPetitionList>();
            return(new Result()
            {
                Code = 0,
                Data = returnPetitionList
            }.ToJSON());
        }