예제 #1
0
        public async Task <List <HotelResponse> > Handle(GetAllHotelsQuery request, CancellationToken cancellationToken)
        {
            var hotels = await _hotelRepository.GetAllHotels();

            return(hotels == null
                ? null
                : _mapper.Map(hotels));
        }
        public async Task <IActionResult> Get()
        {
            var query  = new GetAllHotelsQuery();
            var result = await _mediatr.Send(query, new CancellationToken());

            return(result != null
                ? (IActionResult)Ok(result)
                : NotFound(new { Message = $"No hotels were found." }));
        }
예제 #3
0
        public async Task <PagedList <HotelDto> > Handle(GetAllHotelsQuery request, CancellationToken cancellationToken)
        {
            //get location
            var locations   = _hotelLocationRepo.GetMany(r => r.CityId == request.CityId);
            var locationIds = locations.Select(r => r.Id).ToList();
            //get all Hotel belong to that location
            //var data = _hotelRepo.GetMany(r => locationIds.Contains(r.HotelLocationId.Value));
            var data = await _hotelRepo.GetAll();

            var result = PagedList <Models.Entities.Hotel> .ToPagedList(data.AsQueryable(), request.PageIndex, request.PageSize);


            return(_mapper.Map <PagedList <HotelDto> >(result));
        }
예제 #4
0
 public async Task <IEnumerable <HotelDto> > Get([FromQuery] GetAllHotelsQuery model)
 {
     return(await SendRequestAsync(model));
 }