Пример #1
0
        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
            })));
        }
Пример #2
0
        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));
        }
Пример #3
0
 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));
        }