@using SpotifyAPI.Web; @if (Count is not null) {
@if (Count.Track is not null) {
Track: @Count.Track @if (trackPercent >= 0.01) { (@(trackPercentDisplay)%) }
} @if (Count.Album is not null) {
Album: @Count.Album @if (albumPercent >= 0.01) { (@(albumPercentDisplay)%) }
} @if (Count.Artist is not null) {
Artist: @Count.Artist @if (artistPercent >= 0.1) { (@(artistPercentDisplay)%) }
} @if (Count.User is not null) {
User: @Count.User
}
} @code { [Parameter] public FullTrack Track { get; set; } [Parameter] public PlayCount Count { get; set; } [Parameter] public string Username { get; set; } private string trackLink => $"https://www.last.fm/user/{Username}/library/music/{Track.Artists.First().Name}/_/{Track.Name}"; private string albumLink => $"https://www.last.fm/user/{Username}/library/music/{Track.Album.Artists.First().Name}/{Track.Album.Name}"; private string artistLink => $"https://www.last.fm/user/{Username}/library/music/{Track.Artists.First().Name}"; private string userLink => $"https://www.last.fm/user/{Username}"; private float trackPercent => Count.Track.HasValue && Count.User.HasValue ? (float) Count.Track.Value * 100 / Count.User.Value : 0f; private float albumPercent => Count.Album.HasValue && Count.User.HasValue ? (float) Count.Album.Value * 100 / Count.User.Value : 0f; private float artistPercent => Count.Artist.HasValue && Count.User.HasValue ? (float) Count.Artist.Value * 100 / Count.User.Value : 0f ; private string trackPercentDisplay => string.Format("{0:#,##0.##}", trackPercent); private string albumPercentDisplay => string.Format("{0:#,##0.##}", albumPercent); private string artistPercentDisplay => string.Format("{0:#,##0.##}", artistPercent); }