Beispiel #1
0
        public object GetOrdersWithPagination(PaginFilteringHelper pfHelper, IEnumerable <OrderDto> list)
        {
            list = list.OrderByDescending(x => x.OrderId).ToList();
            if (pfHelper.Search != null)
            {
                pfHelper.Search = pfHelper.Search.ToLower();
                list            = list.Where(x =>
                                             (x.tour.AirportFrom.City + x.tour.AirportFrom.Country + x.tour.AirportFrom.Name +
                                              x.tour.AirportTo.City + x.tour.AirportTo.Country + x.tour.AirportTo.Name).ToLower().Contains(pfHelper.Search.Replace(" ", "")));
            }

            var listPaged = list.Skip((pfHelper.Page - 1) * pfHelper.ItemsPerPage).Take(pfHelper.ItemsPerPage).ToList();

            var json = new
            {
                count = list.Count(),
                list  = listPaged
            };

            return(json);
        }
Beispiel #2
0
        public object GetToursWithPaginFiltering(PaginFilteringHelper pfHelper, IEnumerable <TourDto> list)
        {
            list = list.OrderBy(x => x.TourId).ToList();

            if (pfHelper.AirportFromId != null)
            {
                list = list.Where(x => x.AirportFrom.AirportId == pfHelper.AirportFromId).ToList();
            }

            if (pfHelper.AirportToId != null)
            {
                list = list.Where(x => x.AirportTo.AirportId == pfHelper.AirportToId).ToList();
            }

            if (pfHelper.Day != null)
            {
                list = list.Where(x => x.PossibleDays.Contains(pfHelper.Day)).ToList();
            }

            if (pfHelper.Search != null)
            {
                pfHelper.Search = pfHelper.Search.ToLower();
                list            = list.Where(x =>
                                             (x.AirportFrom.City + x.AirportFrom.Country + x.AirportFrom.Name +
                                              x.AirportTo.City + x.AirportTo.Country + x.AirportTo.Name).ToLower().Contains(pfHelper.Search.Replace(" ", "")));
            }

            var listPaged = list.Skip((pfHelper.Page - 1) * pfHelper.ItemsPerPage).Take(pfHelper.ItemsPerPage).ToList();


            var json = new
            {
                count = list.Count(),
                list  = listPaged
            };

            return(json);
        }