예제 #1
0
        public async Task <MediaItem> GetMediaItemByIdAsync(int id)
        {
            using (_busyStack.GetToken())
            {
                var item = await _mediaItemRepository.GetByIdAsync(id)
                           .ConfigureAwait(true);

                return(_mediaItemMapper.Get(item));
            }
        }
예제 #2
0
        public IList <Playlist> GetAllPlaylists()
        {
            var playlists  = _context.Playlists.AsEnumerable().Select(p => _playlistMapper.Get(p)).ToList();
            var mediaItems = _context.MediaItems.AsEnumerable().Select(p => _mediaItemMapper.Get(p)).ToList();

            foreach (var playlist in playlists)
            {
                playlist.AddRange(mediaItems.Where(p => p.PlaylistId == playlist.Id));
            }

            return(playlists);
        }
예제 #3
0
 public static IEnumerable <MediaItem> GetMany(this IMediaItemMapper mapper, IEnumerable <Data.MediaItem> items, int playlistId)
 {
     return(items.ForEach(p =>
     {
         var item = mapper.Get(p);
         item.PlaylistId = playlistId;
         return item;
     }));
 }