public async Task <Playlist> GetPlaylistById(Guid playlistId, Guid currentUserId) { var playlist = await _context.Set <Playlist>() .Include(x => x.Creator) .Where(x => x.CreatorId == currentUserId || x.IsPrivate == false) .FirstOrDefaultAsync(x => x.Id == playlistId) .ConfigureAwait(false); if (playlist == null) { return(null); } await _context.Entry(playlist) .Collection(x => x.Songs) .Query() .Include(x => x.Song.Band) .LoadAsync() .ConfigureAwait(false); return(playlist); }
public async Task <Album> GetAlbumById(Guid id, bool includeSongs) { var album = await _context.Set <Album>() .Include(x => x.Band) .FirstOrDefaultAsync(x => x.Id == id) .ConfigureAwait(false); if (album == null) { return(null); } if (includeSongs) { await _context.Entry(album) .Collection(x => x.Songs) .Query() .Include(x => x.Song) .LoadAsync() .ConfigureAwait(false); } return(album); }