Ejemplo n.º 1
0
        public async Task <PagedList <LsListDTO> > GetScenarios(ScenarioParameters scenarioParameters)
        {
            var             scenarios     = context.Ls.Where(x => x.LstypeId != (int)LsTypeEnum.Private && x.IsDeleted == false).AsQueryable();
            IQueryable <Ls> searchResults = Enumerable.Empty <Ls>().AsQueryable();

            if (!string.IsNullOrWhiteSpace(scenarioParameters.Keyword))
            {
                searchResults = SearchScenariosByKeyword(scenarioParameters);
            }
            if (!string.IsNullOrWhiteSpace(scenarioParameters.Lsname))
            {
                searchResults = SearchScenariosByName(ref scenarios, scenarioParameters);
            }

            if (searchResults.Count() == 0)
            {
                scenarios = FilterScenarios(ref scenarios, scenarioParameters);

                scenarios = sortService.ApplySort(scenarios, scenarioParameters.OrderBy);
                return(await PagedList <LsListDTO> .ToPagedList(scenarios.Select(x => mapper.Map <LsListDTO>(x)),
                                                                scenarioParameters.PageNumber,
                                                                scenarioParameters.PageSize));
            }
            else
            {
                searchResults = FilterScenarios(ref searchResults, scenarioParameters);

                searchResults = sortService.ApplySort(searchResults, scenarioParameters.OrderBy);
                return(await PagedList <LsListDTO> .ToPagedList(searchResults.Select(x => mapper.Map <LsListDTO>(x)),
                                                                scenarioParameters.PageNumber,
                                                                scenarioParameters.PageSize));
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <Room> GetRoomsForHotel(int hotelId, RoomParameters roomParameters)
        {
            var rooms = _hotelAppContext.Set <Room>().AsQueryable();

            rooms = FilterRooms(ref rooms, roomParameters);
            rooms = rooms.Where(r => r.HotelId == hotelId);
            rooms = _sort.ApplySort(rooms, roomParameters.OrderBy);
            return(PagedList <Room> .ToPagedList(rooms,
                                                 roomParameters.PageNumber,
                                                 roomParameters.PageSize));
        }
Ejemplo n.º 3
0
        public IEnumerable <Reservation> GetAllReservations(ReservationParameters reservationParameters)
        {
            var currentUser   = _userResolverService.GetUser();
            var currentUserId = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;

            var reservations = _hotelAppContext.HotelUsers.Where(x => x.UserId == currentUserId)
                               .Select(x => _hotelAppContext.Rooms
                                       .Where(y => y.HotelId == x.HotelId))
                               .SelectMany(z => z.SelectMany(y => y.Reservations));

            reservations = FilterReservations(ref reservations, reservationParameters);
            reservations = _sort.ApplySort(reservations, reservationParameters.OrderBy);
            return(PagedList <Reservation> .ToPagedList(reservations,
                                                        reservationParameters.PageNumber,
                                                        reservationParameters.PageSize));
        }