public TourAndDetailsDTO GetId(int?id) { TourAndDetailsDTO data; var tours = tour.GetTour(id); var listOC = list.GetListOC(tours.Id.ToString()); var count = country.GetCountry(listOC.CountryId); data = new TourAndDetailsDTO() { Tours = tours, Types = type.GetTourType(tours.TourTypeId), Infos = info.GetTourInfo(tours.InfoId), ListOfCountries = listOC, Countries = count, Regions = region.GetRegion(count.RegionId), }; return(data); }
// GET: api/TourAndDetails/5 public IHttpActionResult Get(int id) { if ((id < service.Get().Count() && id > 0) || service.Get().Where(p => p.Tours.Id == id) != null) { TourAndDetailsDTO example = service.GetId(id); TourAndDetails data; data = new TourAndDetails() { Tours = mapperTour.Map <TourDTO, Tour>(example.Tours), Types = mapperType.Map <TourTypeDTO, TourType>(example.Types), Infos = mapperInfo.Map <TourInfoDTO, TourInfo>(example.Infos), ListOfCountries = mapperList.Map <ListOfCountryDTO, ListOfCountry>(example.ListOfCountries), Countries = mapperCountry.Map <CountryDTO, Country>(example.Countries), Regions = mapperRegion.Map <RegionDTO, Region>(example.Regions), }; return(Ok(data)); } else { return(BadRequest("id was wrong<=0")); } }