Пример #1
0
        public ResponseBody <PageEntity <List <HotelListEntity> > > PostPage([FromBody] HotelQueryParam pageParam)
        {
            var list = _IHotelBLL.GetPage(pageParam);

            return(new ResponseBody <PageEntity <List <HotelListEntity> > > {
                Result = new PageEntity <List <HotelListEntity> > {
                    data = list, total = pageParam.total
                }, Code = "", Message = ""
            });
        }
Пример #2
0
        public IQueryable <HotelListEntity> GetPage(HotelQueryParam pageParam)
        {
            var db     = new LTHWMysqlModel();
            var hotels = from a in db.sline_hotel
                         select new HotelListEntity
            {
                address      = a.address,
                modtime      = a.modtime,
                piclist      = a.piclist,
                price        = a.price,
                sellpoint    = a.sellpoint,
                title        = a.title,
                attrid       = a.attrid,
                bookcount    = a.bookcount,
                recommendnum = a.recommendnum,
                satisfyscore = a.satisfyscore,
                lat          = a.lat,
                lng          = a.lng,
                kindlist     = a.kindlist,
                litpic       = a.litpic,
                decoratetime = a.decoratetime,
                hotelrankid  = a.hotelrankid,
                id           = a.id,
                opentime     = a.opentime,
                telephone    = a.telephone
            };

            if (!string.IsNullOrEmpty(pageParam.title))
            {
                hotels = hotels.Where(p => p.title.Contains(pageParam.title));
            }

            if (!string.IsNullOrEmpty(pageParam.kindlist))
            {
                hotels = hotels.Where(p => ("," + p.kindlist + ",").Contains(("," + pageParam.kindlist + ",")));
            }

            if (!string.IsNullOrEmpty(pageParam.attrid))
            {
                hotels = hotels.Where(p => ("," + p.attrid + ",").Contains(("," + pageParam.attrid + ",")));
            }


            pageParam.total = hotels.Count();
            if (!string.IsNullOrEmpty(pageParam.orderprice))
            {
                if (pageParam.isDesc)
                {
                    hotels = hotels.OrderByDescending(c => c.price).Skip(pageParam.size * (pageParam.page - 1)).Take(pageParam.size);
                }
                else
                {
                    hotels = hotels.OrderBy(c => c.price).Skip(pageParam.size * (pageParam.page - 1)).Take(pageParam.size);
                }
            }
            else
            {
                if (pageParam.isDesc)
                {
                    hotels = hotels.OrderByDescending(c => c.modtime).Skip(pageParam.size * (pageParam.page - 1)).Take(pageParam.size);
                }
                else
                {
                    hotels = hotels.OrderBy(c => c.modtime).Skip(pageParam.size * (pageParam.page - 1)).Take(pageParam.size);
                }
            }
            return(hotels);
        }
Пример #3
0
 public List <HotelListEntity> GetPage(HotelQueryParam pageParam)
 {
     return(_IHotelDAL.GetPage(pageParam).ToList <HotelListEntity>());
 }