/// <summary> /// Marks all fetched scrobbles as not "ToScrobble". /// </summary> public void SelectNone() { foreach (var vm in FetchedScrobbles.Where(i => i.IsEnabled)) { vm.ToScrobble = false; } }
/// <summary> /// Marks all fetched scrobbles as "ToScrobble". /// </summary> public void SelectAll() { foreach (var vm in FetchedScrobbles.Where(i => i.IsEnabled)) { vm.ToScrobble = true; } }
/// <summary> /// Creates a list with scrobbles that will be scrobbled. /// </summary> /// <returns>List with scrobbles.</returns> protected override IEnumerable <Scrobble> CreateScrobbles() { List <Scrobble> scrobbles = new List <Scrobble>(); foreach (var vm in FetchedScrobbles.Where(i => i.ToScrobble)) { scrobbles.Add(new Scrobble(vm.Track.ArtistName, vm.Track.AlbumName, vm.Track.Name, vm.Track.TimePlayed.Value.LocalDateTime.AddSeconds(1)) { Duration = vm.Track.Duration }); } return(scrobbles); }
/// <summary> /// Fetches the recent scrobbles of the user with the given <see cref="Username"/>. /// </summary> public async Task FetchScrobbles() { EnableControls = false; try { OnStatusUpdated("Trying to fetch scrobbles of user " + Username + "..."); FetchedScrobbles.Clear(); var response = await _userApi.GetRecentScrobbles(Username, null, 1, Amount); if (response.Success) { foreach (var s in response) { if (!s.IsNowPlaying.HasValue || !s.IsNowPlaying.Value) { FetchedFriendTrackViewModel vm = new FetchedFriendTrackViewModel(s); vm.ToScrobbleChanged += ToScrobbleChanged; FetchedScrobbles.Add(vm); } } OnStatusUpdated("Successfully fetched scrobbles of user " + Username); } else { OnStatusUpdated("Failed to fetch scrobbles of user " + Username); } } catch (Exception ex) { OnStatusUpdated(string.Format("Fatal error while fetching scrobbles of user {0}. Error: {1}", Username, ex.Message)); } finally { EnableControls = true; } }