Example #1
0
        public static GenreResponse MapFromObject(Genre genre)
        {
            var genreDto = new GenreResponse()
            {
                GenreId = genre.GenreId,
                Name    = genre.Name
            };

            return(genreDto);
        }
Example #2
0
        public static MovieSearchResponse MapFromEntity(ExternalMovie externalMovie, IGenreRepository genreRepository)
        {
            var response = new MovieSearchResponse()
            {
                ExternalId  = externalMovie.ExternalId,
                Title       = externalMovie.Title,
                PosterPath  = externalMovie.PosterPath,
                Adult       = externalMovie.Adult,
                Overview    = externalMovie.Overview,
                ReleaseDate = externalMovie.ReleaseDate
            };

            var genres = genreRepository.GetByExternalIds(externalMovie.GenreIds);

            response.Genres = new List <GenreResponse>();
            foreach (var genre in genres)
            {
                response.Genres.Add(GenreResponse.MapFromObject(genre));
            }

            return(response);
        }
Example #3
0
        public static MovieResponse MapFromObject(Movie movie)
        {
            //Create list of GenreResponses from the movies many-many map
            var genres = new List <GenreResponse>();

            foreach (var movieGenre in movie.MovieGenres)
            {
                genres.Add(GenreResponse.MapFromObject(movieGenre.Genre));
            }

            MovieResponse movieDto = new MovieResponse()
            {
                MovieId      = movie.MovieId,
                Title        = movie.Title,
                Description  = movie.Description,
                Year         = movie.Year,
                ImageUrl     = movie.ImageUrl,
                PlaybackTime = (movie.PlaybackTime.HasValue) ? movie.PlaybackTime.Value.TotalSeconds : 0,
                Duration     = (movie.VideoFile != null) ? movie.VideoFile.Duration.TotalSeconds : (double?)null,
                Genres       = genres
            };

            return(movieDto);
        }