public async Task <IActionResult> Search(TourSearchModel searchCriteria) { List <Tour> tours = await _context.Tours.Where(t => t.Country == searchCriteria.Country).ToListAsync(); return(View("List", tours.Select(t => new TourViewModel { Country = t.Country, StartDate = t.StartDate, EndDate = t.EndDate, Description = t.Description, Id = t.Id, MaxResrvations = t.MaxResrvations }))); }
public async Task <List <TourDTO> > ShowFilteredToursAsync(TourSearchModel SearchModel) { var result = await database.Tours.GetAllAsync(); if (SearchModel != null) { result.AsQueryable(); if (!string.IsNullOrEmpty(SearchModel.CountryNames)) { result = result.Where(t => t.CountryNames == SearchModel.CountryNames); } if (SearchModel.HotTour.HasValue) { result = result.Where(t => t.HotTour == SearchModel.HotTour); } } return(mapper.Map <IEnumerable <Tour>, List <TourDTO> >(result)); }
public Task <List <TourDTO> > Post([FromBody] TourSearchModel model) { return(tourCatalogueService.ShowFilteredToursAsync(model)); }
public IHttpActionResult FindTours([FromBody] TourSearchModel searchModel) { var tours = service.GetTours(mapper.Map <TourParameters>(searchModel)); return(ReturnResult(tours)); }