Exemplo n.º 1
0
        public static MovieQueueResponse MapFromObject(MovieQueue obj)
        {
            var movieQueueDto = new MovieQueueResponse()
            {
                Name = obj.Name
            };

            movieQueueDto.Movies = new List <MovieResponse>();
            foreach (var movie in obj.Movies)
            {
                movieQueueDto.Movies.Add(MovieResponse.MapFromObject(movie));
            }

            return(movieQueueDto);
        }
Exemplo n.º 2
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);
        }