public async Task <IActionResult> GetShowCollection(Guid tourId, [ModelBinder(BinderType = typeof(ArrayModelBinder))] IEnumerable <Guid> showIds) { if (showIds == null || !showIds.Any()) { return(BadRequest()); } // check if the tour exists if (!await _tourManagementRepository.TourExists(tourId)) { return(NotFound()); } var showEntities = await _tourManagementRepository.GetShows(tourId, showIds); if (showIds.Count() != showEntities.Count()) { return(NotFound()); } var showCollectionToReturn = Mapper.Map <IEnumerable <Show> >(showEntities); return(Ok(showCollectionToReturn)); }
public async Task <IActionResult> GetShows(Guid tourId) { if (!(await _tourManagementRepostitory.TourExists(tourId))) { return(NotFound()); } var showsFromRepo = await _tourManagementRepostitory.GetShows(tourId); var shows = Mapper.Map <IEnumerable <Show> >(showsFromRepo); return(Ok(shows)); }
public async Task <IActionResult> Get(string tourId) { try { var showsFromRepo = await _tourManagementRepository.GetShows(tourId); var shows = Mapper.Map <IEnumerable <Show> >(showsFromRepo); return(Ok(shows)); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(Ok()); }