Exemplo n.º 1
0
        public async Task <IActionResult> GetGuestStaysDisplay([FromQuery] GuestStayUserParams guestStayParams)
        {
            var guestStaysToReturn = _mapper.Map <IEnumerable <GuestStayForDisplayDto> > (
                await _guestStayService.GetGuestStays(guestStayParams));

            return(Ok(guestStaysToReturn));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetGuestStaysPagination([FromQuery] GuestStayUserParams guestStayParams)
        {
            var stayPagList = await _guestStayService.GetGuestStaysPagination(guestStayParams);

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

            return(Ok(stayPagList));
        }
Exemplo n.º 3
0
        private IQueryable <Stay> ProcessFilter(IQueryable <Stay> stays, GuestStayUserParams userParams, Expression <Func <Stay, bool> > filter)
        {
            if (filter != null)
            {
                stays = stays.Where(filter);
            }

            if (userParams != null)
            {
                if (userParams.DodId != null)
                {
                    stays = stays.Where(s => s.Guest.DodId == userParams.DodId);
                }

                if (!String.IsNullOrWhiteSpace(userParams.LastName))
                {
                    stays = stays.Where(s => s.Guest.LastName.Contains(userParams.LastName.ToUpper()));
                }

                if (userParams.RoomNumber != null)
                {
                    stays = stays.Where(s => s.Room.RoomNumber.Equals(userParams.RoomNumber));
                }

                if (userParams.RoomId != null)
                {
                    stays = stays.Where(s => s.RoomId == userParams.RoomId);
                }

                if (userParams.GuestId != null)
                {
                    stays = stays.Where(s => s.Guest.Id == userParams.GuestId);
                }

                if (userParams.CurrentStaysOnly)
                {
                    stays = stays.Where(s => (s.CheckedOut == false && s.CheckedIn == true));
                }

                if (userParams.BuildingId != null)
                {
                    stays = stays.Where(s => s.BuildingId == userParams.BuildingId);
                }

                if (userParams.ServiceId != null)
                {
                    stays = stays.Where(s => s.Guest.Rank.ServiceId == userParams.ServiceId);
                }
            }

            return(stays);
        }
Exemplo n.º 4
0
 public async Task <PagedList <Stay> > GetGuestStaysPagination(GuestStayUserParams guestStayParams)
 {
     return(await _guestStayRepo.GetGuestStaysPagination(
                guestStayParams,
                new Expression <Func <Stay, object> >[] {
         s => s.Guest,
         s => s.Guest.Rank,
         s => s.Guest.Rank.Service,
         s => s.Guest.Unit,
         s => s.Room,
         s => s.Building
     }, null
                ));
 }
Exemplo n.º 5
0
        public async Task <IEnumerable <Stay> > GetGuestStays(
            GuestStayUserParams userParams = null,
            Expression <Func <Stay, object> >[] includeProperties = null,
            Expression <Func <Stay, bool> > filter = null)
        {
            var stays = _context.Stays.AsQueryable();

            if (includeProperties != null)
            {
                stays = this.ProcessProperties(stays, includeProperties);
            }

            stays = this.ProcessFilter(stays, userParams, filter);

            return(await stays.ToListAsync());
        }
Exemplo n.º 6
0
 public async Task <IEnumerable <Stay> > GetGuestStays(GuestStayUserParams guestStayParams = null, Expression <Func <Stay, bool> > filter = null)
 {
     return(await _guestStayRepo.GetGuestStays(
                guestStayParams,
                new Expression <Func <Stay, object> >[] {
         s => s.Guest,
         s => s.Guest.Rank,
         s => s.Guest.Rank.Service,
         s => s.Guest.Unit,
         s => s.Room,
         s => s.Building,
         s => s.Building.BuildingCategory
     },
                filter
                ));
 }
Exemplo n.º 7
0
        public async Task <PagedList <Stay> > GetGuestStaysPagination(
            GuestStayUserParams userParams,
            Expression <Func <Stay, object> >[] includeProperties = null,
            Expression <Func <Stay, bool> > filter = null)
        {
            var stays = _context.Stays.AsQueryable();

            if (includeProperties != null)
            {
                stays = this.ProcessProperties(stays, includeProperties);
            }

            stays = this.ProcessFilter(stays, userParams, filter);

            stays = stays.OrderByDescending(s => s.CheckInDate);

            return(await PagedList <Stay> .CreateAsync(stays, userParams.PageNumber, userParams.PageSize));
        }