コード例 #1
0
ファイル: CastService.cs プロジェクト: kailakers/MovieShopWeb
        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);
        }