private async Task <Albums> RemoveDuplicateAlbum(ItemClickEventArgs e) { string response = await apiConnect.GetAsJsonAsync("https://api.deezer.com/artist/" + (e.ClickedItem as Artist).id + "/albums?limit=1000"); Albums albums = JsonConvert.DeserializeObject <Albums>(response); List <string> allTitle = new List <string>(); foreach (Album album in albums.data) { allTitle.Add(album.title); } foreach (string title in allTitle) { int count = 0; foreach (Album album in albums.data.ToList()) { if (album.title.Contains(title)) { count++; if (count > 1) { albums.data.Remove(album); } } } } return(albums); }
private async void InitializeUser() { textWelcomeUser.Text = "Welcome " + connectedUser.username; personPicture.Initials = (connectedUser.username[0].ToString() + connectedUser.username[1].ToString()).ToUpper(); string response = await apiConnect.GetAsJsonAsync("http://localhost/api/level/level.php"); List <Levels> levels = JsonConvert.DeserializeObject <List <Levels> >(response); double amountActualLevel = Convert.ToDouble(levels[Convert.ToInt16(connectedUser.level_id) - 1].amount_xp); double amountNextLevel = 38400; if (connectedUser.level_id != "10") { amountNextLevel = Convert.ToDouble(levels[Convert.ToInt16(connectedUser.level_id)].amount_xp); } double calcul = Convert.ToDouble(((Convert.ToDouble(connectedUser.xp) - amountActualLevel) / (amountNextLevel - amountActualLevel)) * 100); double value = Math.Round(calcul); progressUser.Value = value; textLvl.Text = "Lvl " + connectedUser.level_id; string responseTwo = await apiConnect.PostAsJsonAsync(connectedUser.username, "http://localhost/api/stats/getkdr.php"); List <string> kdr = JsonConvert.DeserializeObject <List <string> >(responseTwo); textVictories.Text = "Win(s): " + kdr[0]; }
private async void InitializeContentDialog() { textCongratsUser.Text = "Congratulations " + userConnected.username; personPicture.Initials = (userConnected.username[0].ToString() + userConnected.username[1].ToString()).ToUpper(); if (userConnected.level_id != "10") { textLvlActual.Text = "Lvl " + userConnected.level_id; textLvlNext.Text = "Lvl " + (Convert.ToInt16(userConnected.level_id) + 1).ToString(); } else { textLvlActual.Text = "Lvl " + userConnected.level_id; textLvlNext.Text = "Lvl " + userConnected.level_id; } string response = await apiConnect.GetAsJsonAsync("http://localhost/api/level/level.php"); List <Levels> levels = JsonConvert.DeserializeObject <List <Levels> >(response); double amountActualLevel = Convert.ToDouble(levels[Convert.ToInt16(userConnected.level_id) - 1].amount_xp); progressUser.Minimum = amountActualLevel; double amountNextLevel = 38400; if (userConnected.level_id != "10") { amountNextLevel = Convert.ToDouble(levels[Convert.ToInt16(userConnected.level_id)].amount_xp); progressUser.Maximum = amountNextLevel; amountlevelUpNext = 0; if (userConnected.level_id != "9") { amountlevelUpNext = Convert.ToDouble(levels[Convert.ToInt16(userConnected.level_id) + 1].amount_xp); } } double value = amountActualLevel + Convert.ToDouble(userConnected.xp); progressUser.Value = value; await Task.Delay(2000); if (userConnected.level_id != "10") { AddXp(amountNextLevel, Convert.ToDouble(userConnected.xp)); } }
private async void clickOnSearch(string url) { if (textSearch.Text != "") { ProgressAnimation(true, progressFound, textEmptyFound); string response = await apiConnect.GetAsJsonAsync(url + textSearch.Text); if (classType == 1) { listArtists = deserializeArtist(response); //Deserialize the response of the php files to class Artist. ProgressAnimation(false, progressFound, textEmptyFound); if (listArtists.data.Count != 0) { if (listArtistsAdd.data.Count != 0) { List <Artist> listArtistCleared = listArtists.data; foreach (Artist artistListArtist in listArtists.data.ToList()) { foreach (Artist artistListArtistAdd in listArtistsAdd.data) { if (artistListArtist.id == artistListArtistAdd.id) { listArtistCleared.Remove(artistListArtist); } } } listArtists.data = listArtistCleared; } ShowListView(true, gridFound, textEmptyFound); chooseClass(); } else { ShowListView(false, gridFound, textEmptyFound); textEmptyFound.Text = "NO RESULT FOUND"; } } else if (classType == 2) { listAlbums = deserializeAlbum(response); //Deserialize the response of the php files to class Album. ProgressAnimation(false, progressFound, textEmptyFound); if (listAlbums.data.Count != 0) { if (listAlbumsAdd.data.Count != 0) { List <Album> listAlbumsCleared = listAlbums.data; foreach (Album albumListAlbum in listAlbums.data.ToList()) { foreach (Album albumListAlbumAdd in listAlbumsAdd.data) { if (albumListAlbum.id == albumListAlbumAdd.id) { listAlbumsCleared.Remove(albumListAlbum); } } } listAlbums.data = listAlbumsCleared; } ShowListView(true, gridFound, textEmptyFound); chooseClass(); } else { ShowListView(false, gridFound, textEmptyFound); textEmptyFound.Text = "NO RESULT FOUND"; } } else { listTracks = deserializeTrack(response); //Deserialize the response of the php files to class Track. ProgressAnimation(false, progressFound, textEmptyFound); if (listTracks.data.Count != 0) { if (listTracksAdd.data.Count != 0) { List <Track> listTracksCleared = listTracks.data; foreach (Track trackListTrack in listTracks.data.ToList()) { foreach (Track trackListTrackAdd in listTracksAdd.data) { if (trackListTrack.id == trackListTrackAdd.id) { listTracksCleared.Remove(trackListTrack); } } } listTracks.data = listTracksCleared; } ShowListView(true, gridFound, textEmptyFound); chooseClass(); } else { ShowListView(false, gridFound, textEmptyFound); textEmptyFound.Text = "NO RESULT FOUND"; } } } else { errorTextBoxStoryboard.Begin(); } }