Beispiel #1
0
        /// <summary>
        /// Get movie cover by movie id
        /// </summary>
        /// <param name="movieId">Movie id</param>
        /// <returns>Movie cover</returns>
        public async Task <MovieImageDto> GetMovieCover(Guid movieId)
        {
            var cover = await MovieImageRepo
                        .GetAll()
                        .AsNoTracking()
                        .Include(i => i.Image)
                        .FirstOrDefaultAsync(i => i.MovieId == movieId && i.ImageType == MovieImageType.Cover);

            if (cover == null)
            {
                return(null);
            }

            return(Mapper.Map <MovieImageDto>(cover));
        }
Beispiel #2
0
        /// <summary>
        /// Gets all movies
        /// </summary>
        /// <returns>List of movies for list/table</returns>
        public async Task <IEnumerable <MovieForList> > GetMovies()
        {
            var movies = await MovieRepo
                         .GetAll()
                         .ToListAsync();

            var result = Mapper.Map <IEnumerable <MovieForList> >(movies);

            foreach (var m in result)
            {
                var thumbnail = await MovieImageRepo
                                .GetAll(i => i.MovieId == m.Id && i.ImageType == MovieImageType.Cover)
                                .Include(i => i.Image)
                                .FirstOrDefaultAsync();

                if (thumbnail != null)
                {
                    m.ThumbnailUrl = thumbnail.Image.Url;
                }
            }

            return(result);
        }