public async Task <IActionResult> GetHotels([FromQuery] HotelParams hotelParams) { var hotels = await _repo.GetHotels(hotelParams); var hotelsToReturn = _mapper.Map <IEnumerable <HotelForListDto> >(hotels); Response.AddPagination(hotels.CurrentPage, hotels.PageSize, hotels.TotalCount, hotels.TotalPages); return(Ok(hotelsToReturn)); }
public void UpdateHotel(Guid id, HotelParams param) { int currentHotelIndex = hotels.FindIndex(hotel => hotel.IdHotel == id); if (String.IsNullOrWhiteSpace(param.Name) || String.IsNullOrWhiteSpace(param.Country) || param.Rating == 0) { Console.WriteLine("Не все поля заполнены! Для изменения отеля заполните все поля!"); return; } hotels[currentHotelIndex].Name = param.Name; hotels[currentHotelIndex].Rating = param.Rating; hotels[currentHotelIndex].Country = param.Country; repo.UpdatingListHotels(hotels); }
public async Task <PagedList <Hotel> > GetHotels(HotelParams hotelParams) { var hotels = _context.Hotels; return(await PagedList <Hotel> .CreateAsync(hotels, hotelParams.PageNumber, hotelParams.PageSize)); }