Example #1
0
        public async Task <IActionResult> GetRoomsDisplay([FromQuery] RoomUserParams userParams)
        {
            var rooms = _mapper.Map <IEnumerable <RoomForDisplayDto> > (
                await _guestStayService.GetRooms(userParams));

            return(Ok(rooms));
        }
Example #2
0
        private IQueryable <Room> ProcessFilter(IQueryable <Room> rooms, RoomUserParams userParams, Expression <Func <Room, bool> > filter)
        {
            if (filter != null)
            {
                rooms = rooms.Where(filter);
            }

            if (userParams.BuildingId != null)
            {
                rooms = rooms.Where(r => r.BuildingId == userParams.BuildingId);
            }

            if (!String.IsNullOrWhiteSpace(userParams.RoomNumber))
            {
                rooms = rooms.Where(r => r.RoomNumber.Equals(userParams.RoomNumber));
            }

            if (userParams.OnlyAvailableRooms)
            {
                var stays = _context.Stays.AsQueryable();

                if (userParams.OnlyAvailableRooms == true && userParams.BuildingId != 0)
                {
                    stays = _context.Stays.Where(s => s.CheckedOut == false &&
                                                 s.CheckedIn == true &&
                                                 !(DateTime.Compare(s.CheckInDate.Date, DateTime.Today) > 0) &&
                                                 s.BuildingId == userParams.BuildingId);
                }

                rooms = rooms.Where(r => (stays.Where(s => s.RoomId == r.Id).Count()) <
                                    (r.Building.BuildingCategory.InSurge? r.SurgeCapacity : r.Capacity));
            }
            return(rooms);
        }
Example #3
0
        public async Task <PagedList <Room> > GetRoomsPagination(RoomUserParams userParams)
        {
            var rooms = await _roomsRepo.GetRoomsPagination(userParams,
                                                            null,
                                                            new Expression <Func <Room, object> >[] {
                r => r.Building
            });

            return(rooms);
        }
Example #4
0
        public async Task <IActionResult> GetRoomsPagination([FromQuery] RoomUserParams userParams)
        {
            var rms = await _guestStayService.GetRoomsPagination(userParams);

            Response.AddPagination(rms.CurrentPage,
                                   rms.PageSize,
                                   rms.TotalCount,
                                   rms.TotalPages);

            return(Ok(rms));
        }
Example #5
0
        public async Task <IEnumerable <Room> > GetRooms(RoomUserParams userParams)
        {
            var rooms = await _roomsRepo.GetRooms(
                userParams,
                null,
                new Expression <Func <Room, object> >[] {
                r => r.Building
            });

            return(rooms);
        }
Example #6
0
        public async Task <IEnumerable <Room> > GetRooms(
            RoomUserParams userParams,
            Expression <Func <Room, bool> > filter = null,
            Expression <Func <Room, object> >[] includeProperties = null
            )
        {
            var rooms = _context.Rooms.OrderBy(r => r.RoomNumber).AsQueryable();

            if (includeProperties != null)
            {
                rooms = ProcessProperties(rooms, includeProperties);
            }

            rooms = ProcessFilter(rooms, userParams, filter);
            return(await rooms.ToListAsync());
        }
Example #7
0
        public async Task <IActionResult> GetAvaliableRooms([FromQuery] RoomUserParams userParams)
        {
            var rooms = await _guestStayService.GetRoomsPagination(userParams);

            var roomsToReturn = _mapper.Map <IEnumerable <RoomForCheckinDto> > (rooms);

            foreach (var room in roomsToReturn)
            {
                room.CurrentGuestCount = await _guestStayService.GetAvailableRoomCount(room.Id);
            }

            Response.AddPagination(rooms.CurrentPage,
                                   rooms.PageSize,
                                   rooms.TotalCount,
                                   rooms.TotalPages);

            return(Ok(roomsToReturn));
        }
Example #8
0
        public async Task <PagedList <Room> > GetRoomsPagination(
            RoomUserParams userParams,
            Expression <Func <Room, bool> > filter = null,
            Expression <Func <Room, object> >[] includeProperties = null

            )
        {
            var rooms = _context.Rooms.OrderBy(r => r.RoomNumber).AsQueryable();

            if (includeProperties != null)
            {
                rooms = ProcessProperties(rooms, includeProperties);
            }

            rooms = ProcessFilter(rooms, userParams, filter);

            return(await PagedList <Room> .CreateAsync(rooms, userParams.PageNumber, userParams.PageSize));
        }
Example #9
0
        public async Task <IActionResult> GetRooms([FromQuery] RoomUserParams userParams)
        {
            var rooms = await _guestStayService.GetRooms(userParams);

            return(Ok(rooms));
        }