public async Task <CastDetailsResponseModel> GetCastDetailsWithMovies(int id) { var cast = await _castRepository.GetByIdAsync(id); var castMovies = new List <MovieResponseModel>(); foreach (var movie in cast.MovieCasts) { castMovies.Add(new MovieResponseModel() { Id = movie.MovieId, PosterUrl = movie.Movie.PosterUrl, Title = movie.Movie.Title }); } CastDetailsResponseModel castDetailResponseModel = new CastDetailsResponseModel(); var response = castDetailResponseModel; response.Id = cast.Id; response.Name = cast.Name; response.Gender = cast.Gender; response.TmdbUrl = cast.TmdbUrl; response.ProfilePath = cast.ProfilePath; response.Movies = castMovies; return(response); }
public async Task <CastDetailsResponseModel> GetCastDetailsWithMovies(int id) { var cast = await _castRepository.GetByIdAsync(id); if (cast == null) { throw new NotFoundException("Cast", id); } var movies = new List <MovieResponseModel>(); foreach (var thing in cast.MovieCasts) { movies.Add(new MovieResponseModel { Id = thing.MovieId, PosterUrl = thing.Movie.PosterUrl, ReleaseDate = (DateTime)thing.Movie.ReleaseDate, Title = thing.Movie.Title }); } var response = new CastDetailsResponseModel { Id = cast.Id, Name = cast.Name, Gender = cast.Gender, TmdbUrl = cast.TmdbUrl, ProfilePath = cast.ProfilePath, Movies = movies }; return(response); }
public async Task <CastDetailsResponseModel> GetCastDetailsWithMovies(int id) { var cast = await _castRepository.GetByIdAsync(id); var respose = new CastDetailsResponseModel { Id = cast.Id, Name = cast.Name, Gender = cast.Gender, ProfilePath = cast.ProfilePath, TmdbUrl = cast.TmdbUrl }; var castMovies = new List <MovieResponseModel>(); foreach (var m in cast.MovieCasts) { var movieResponse = new MovieResponseModel { Id = m.Movie.Id, Title = m.Movie.Title, PosterUrl = m.Movie.PosterUrl, ReleaseDate = m.Movie.ReleaseDate.Value }; castMovies.Add(movieResponse); } respose.Movies = castMovies; return(respose); }
public async Task <CastDetailsResponseModel> GetCastDetailsWithMovies(int id) { var cast = await _castRepository.GetByIdAsync(id); var castDetailsResponseModel = new CastDetailsResponseModel(); if (cast != null) { castDetailsResponseModel.Id = cast.Id; castDetailsResponseModel.Gender = cast.Gender; castDetailsResponseModel.Name = cast.Name; castDetailsResponseModel.ProfilePath = cast.ProfilePath; castDetailsResponseModel.TmdbUrl = cast.TmdbUrl; List <MovieResponseModel> movieResponseModels = new List <MovieResponseModel>(); foreach (var movieCast in cast.MovieCasts) { Movie movie = movieCast.Movie; var response = new MovieResponseModel { Id = movie.Id, Title = movie.Title, PosterUrl = movie.PosterUrl, ReleaseDate = movie.ReleaseDate }; } } return(castDetailsResponseModel); }
public async Task <CastDetailsResponseModel> GetCastDetailsById(int id) { var cast = await _castRepository.GetCastDetailById(id); if (cast == null) { throw new Exception(); } List <MovieResponseModel> movieResponseModel = new List <MovieResponseModel>(); foreach (var movieCast in cast.MovieCasts) { movieResponseModel.Add(new MovieResponseModel { Id = movieCast.MovieId, Title = movieCast.Movie.Title, PosterUrl = movieCast.Movie.PosterUrl, ReleaseDate = movieCast.Movie.ReleaseDate }); } CastDetailsResponseModel castDetailsResponseModel = new CastDetailsResponseModel { Id = cast.Id, Gender = cast.Gender, ProfilePath = cast.ProfilePath, Name = cast.Name, TmdbUrl = cast.TmdbUrl, Movies = movieResponseModel }; return(castDetailsResponseModel); }
public async Task <CastDetailsResponseModel> GetCastAsync(int id) { var cast = await _castRepository.GetByIdAsync(id); var castResult = new CastDetailsResponseModel(); castResult.Name = cast.Name; castResult.Gender = cast.Gender; castResult.TmdbUrl = cast.TmdbUrl; castResult.ProfilePath = cast.ProfilePath; castResult.Id = cast.Id; castResult.CastId = cast.Id; castResult.MovieId = new List <MovieDetailsResponseModel>(); castResult.Movie = new List <MovieDetailsResponseModel>(); foreach (var movieCast in cast.MovieCast) { castResult.Movie.Add( new MovieDetailsResponseModel { Title = movieCast.Movie.Title, PosterUrl = movieCast.Movie.PosterUrl, Overview = movieCast.Movie.Overview, Id = movieCast.Movie.Id }); } return(castResult); }
public async Task <CastDetailsResponseModel> GetCastDetailsWithMovies(int id) { var cast = await _castRepository.GetByIdAsync(id); var ReturnedCast = new CastDetailsResponseModel { Id = cast.Id, Name = cast.Name, Gender = cast.Gender, TmdbUrl = cast.TmdbUrl, ProfilePath = cast.ProfilePath }; return(ReturnedCast); }
public async Task <CastDetailsResponseModel> GetCastDetailsWithMovies(int id) { var cast = await _castRepository.GetByIdAsync(id); if (cast == null) { return(null); } var resp = new CastDetailsResponseModel() { Id = cast.Id, Gender = cast.Gender, Name = cast.Name, ProfilePath = cast.ProfilePath, TmdbUrl = cast.TmdbUrl }; return(resp); }
public async Task <CastDetailsResponseModel> GetCastDetailsWithMovies(int id) { var dbcasts = await _castRepository.GetByIdAsync(id); if (dbcasts == null) { throw new Exception("No Casts Found"); } var response = new CastDetailsResponseModel { Id = dbcasts.Id, Name = dbcasts.Name, Gender = dbcasts.Gender, TmdbUrl = dbcasts.TmdbUrl, ProfilePath = dbcasts.ProfilePath }; return(response); }