public async void send_comment(string comment_txt, string type, string id) { Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string url = type + "/addcomment/" + id; string comment_data = "user_id=" + Singleton.Instance.Current_user.id + "&content=" + WebUtility.UrlEncode(comment_txt) + "&secureKey=" + secureKey; // HTTP_POST -> URL + DATA var response = await request.post_request(type + "/addcomment/" + id, comment_data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { await new MessageDialog("Comment SEND").ShowAsync(); } else await new MessageDialog("Comment KO").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog(exception.Message, "Comment POST Error").ShowAsync(); }
// type = “News” | “Albums” | “Concerts” public static async Task<bool> like(string type, string id) { Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string url = "/likes/save"; string data = "like[user_id]=" + Singleton.Instance.Current_user.id + "&like[typeObj]=" + type + "&like[obj_id]=" + id + "&user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey; // HTTP_POST -> URL + DATA var response = await request.post_request(url, data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { //await new MessageDialog("Like OK").ShowAsync(); return true; } else await new MessageDialog("Erreur lors du like").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors du like").ShowAsync(); return false; }
static public async Task<bool> send_msg(int dest, string msg) { //messages/save?message[user_id]=4&message[dest_id]=1&message[msg]=salut_comment_va_looooooool&user_id=4&secureKey=694229ac41695d8a8f00c9a6a04206911180a1f11f0543b3112734abdce47071 Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string msg_data = "message[user_id]=" + Singleton.Instance.Current_user.id + "&message[dest_id]=" + dest.ToString() + "&message[msg]=" + WebUtility.UrlEncode(msg) + "&user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey; // HTTP_POST -> URL + DATA var response = await request.post_request("/messages/save?", msg_data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { //await new MessageDialog("msg SEND").ShowAsync(); return true; } else await new MessageDialog("Erreur lors de l'envoi du message").ShowAsync(); } catch (Exception e) { exception = e; } return false; }
// Method called in the ConnectionCommand file public async void classic_connection() { Exception exception = null; var request = new Http_post(); try { // HTTP_POST -> URL + DATA var response = await request.post_request("login", "email=" + mail + "&password="******"message"); if (json.ToString() == "Success") { Get_User(response); //await new MessageDialog("Email = " + mail + "\nPasswd = " + passwd, "Connexion OK").ShowAsync(); ((Frame)Window.Current.Content).Navigate(typeof(SoonZik.Views.Home)); } else await new MessageDialog("Une erreur de combinaison E-mail/Mot de passe est survenue").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur de connexion au server").ShowAsync(); }
async void send_feedback() { Exception exception = null; var request = new Http_post(); try { if (!check_value()) { await new MessageDialog("Remplissez tous les champs").ShowAsync(); return; } //“bug”, “payment”, “account”, “other” --> object type if (index_cb == 0) object_type = "bug"; else if (index_cb == 1) object_type = "payment"; else if (index_cb == 2) object_type = "account"; else if (index_cb == 3) object_type = "other"; else return; string feed_data = "feedback[email]=" + WebUtility.UrlEncode(email) + "&feedback[type_object]=" + object_type + "&feedback[object]=" + WebUtility.UrlEncode(objet) + "&feedback[text]=" + WebUtility.UrlEncode(txt); // HTTP_POST -> URL + DATA var response = await request.post_request("/feedbacks/save/", feed_data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { await new MessageDialog("feedback ok").ShowAsync(); } else await new MessageDialog("Erreur lors de l'envoi du feedback").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de l'envoi du feedback").ShowAsync(); }
public async void remove_follow() { Exception exception = null; var request = new Http_post(); try { string post_data = "user_id=" + Singleton.Instance.Current_user.id.ToString() + "&follow_id=" + artist.id + "&secureKey=" + await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); var response = await request.post_request("users/unfollow", post_data); var json = JObject.Parse(response).SelectToken("message"); // Debug if (json.ToString() == "Success") { //await new MessageDialog("Remove follow OK").ShowAsync(); Singleton.Instance.Current_user.follows.Remove(artist); add_follow_btn = Visibility.Visible; remove_follow_btn = Visibility.Collapsed; followers.Remove(Singleton.Instance.Current_user); } else await new MessageDialog("Erreur lors du unfollow de l'utilisateur").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog(exception.Message, "Erreur lors du unfollow de l'utilisateur").ShowAsync(); }
public async void vote(int id) { Exception exception = null; var request = new Http_post(); try { string post_data = "user_id=" + Singleton.Instance.Current_user.id.ToString() + "&artist_id=" + id.ToString() + "&secureKey=" + await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); var response = await request.post_request("battles/" + selected_battle.id.ToString() + "/vote", post_data); var json = JObject.Parse(response).SelectToken("code"); // Debug. 200 = success if (json.ToString() == "200" || json.ToString() == "201") { await new MessageDialog("Le vote a été comptabilisé").ShowAsync(); // SET NEW VOTE Vote new_vote = new Vote(); new_vote.user_id = Singleton.Instance.Current_user.id; new_vote.artist_id = id; selected_battle.votes.Add(new_vote); battlelist[battlelist.IndexOf(selected_battle)].result_visibility = Visibility.Visible; battlelist[battlelist.IndexOf(selected_battle)].btn_visibility = Visibility.Collapsed; battlelist[battlelist.IndexOf(selected_battle)].votes.Add(new_vote); } else await new MessageDialog("Erreur lors du vote").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors du vote").ShowAsync(); }
async void update_playlist() { Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string musics_id = ""; foreach (var music in playlist_update_music) musics_id += music.id.ToString() + ","; var data_update = "user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey + "&id=" + selected_playlist.id + "&playlist[user_id]=" + Singleton.Instance.Current_user.id.ToString() + "&playlist[name]=" + WebUtility.UrlEncode(selected_playlist.name) + "&playlist[music]=[" + musics_id.Remove(musics_id.Length - 1) + "]"; var response_update = await request.post_request("/playlists/update", data_update); var jsonbis = JObject.Parse(response_update).SelectToken("message"); if (jsonbis.ToString() == "Created") await new MessageDialog("Playlist mise à jour").ShowAsync(); else await new MessageDialog("Erreur lors de la mise à jour de la playlist").ShowAsync(); // clear value & list music_list_to_add.Clear(); playlist_name = ""; playlist_list.Clear(); playlist_update_music.Clear(); load_playlist(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de la mise à jour de la playlist").ShowAsync(); }
public async void update_user() { Exception exception = null; var request = new Http_post(); try { string user_data = "&user_id=" + Singleton.Instance.Current_user.id.ToString() + "&secureKey=" + await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()) + "&user[username]=" + edit_user.username + "&user[email]=" + edit_user.email + "&user[password]=" + passwd + "&user[language]=" + edit_user.language + "&user[birthday]=" + edit_user.birthday + "&user[fname]=" + edit_user.fname + "&user[lname]=" + edit_user.lname + "&user[phoneNumber]=" + edit_user.phoneNumber + "&user[description]=" + edit_user.description; if (check_addr(edit_user.address)) user_data += "&address[numberStreet]=" + edit_user.address.numberStreet + "&address[street]=" + edit_user.address.street + "&address[zipcode]=" + edit_user.address.zipcode + "&address[city]=" + edit_user.address.city + "&address[country]=" + edit_user.address.country + "&address[complement]=" + edit_user.address.complement; var response = await request.post_request("users/update", user_data); var json = JObject.Parse(response).SelectToken("message"); var json1 = JObject.Parse(response).SelectToken("content"); // Debug if (json.ToString() == "Created") { await new MessageDialog("Mise à jour du profil réussie").ShowAsync(); Singleton.Instance.Current_user = edit_user; } else await new MessageDialog("Erreur lors de la mise à jour du profil").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de la mise à jour du profil").ShowAsync(); }
async public void set_note(int note) { Exception exception = null; var request = new Http_post(); try { string url = "/musics/" + music.id.ToString() + "/note/" + note.ToString(); string data = "user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); // HTTP_POST -> URL + DATA var response = await request.post_request(url, data); var json = JObject.Parse(response).SelectToken("message"); //if (json.ToString() == "Created") // await new MessageDialog("note OK").ShowAsync(); //else // await new MessageDialog("note KO").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog(exception.Message, "Erreur lors de la notation de la musique").ShowAsync(); }
}// buy_cart_after_pp_validation async public void buy_cart_after_pp_validation() { Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string pack_data = "user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey + "&paypal[payment_id]=" + pp_transac_id; // HTTP_POST -> URL + DATA var response = await request.post_request("purchases/buycart", pack_data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { // empty cart list_cart.Clear(); cart_price = 0.0; await new MessageDialog("Achat du panier effectué").ShowAsync(); } } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de l'achat du panier").ShowAsync(); }
async public static void add_to_cart(int user_id, int obj_id, string obj_type, int gift_user_id) { Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string pack_data = "user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey + "&cart[user_id]=" + user_id + "&cart[typeObj]=" + obj_type + "&cart[obj_id]=" + obj_id; if (gift_user_id > 0) pack_data += "&gift_user_id=" + gift_user_id; // HTTP_POST -> URL + DATA var response = await request.post_request("carts/save", pack_data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { await new MessageDialog("Ajout au panier confirmé").ShowAsync(); } else await new MessageDialog("Erreur lors de l'ajout dans le panier").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de l'ajout dans le panier").ShowAsync(); }
public async void remove_friend() { Exception exception = null; var request = new Http_post(); try { string post_data = "user_id=" + Singleton.Instance.Current_user.id.ToString() + "&friend_id=" + user.id + "&secureKey=" + await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); var response = await request.post_request("users/delfriend", post_data); var json = JObject.Parse(response).SelectToken("message"); // Debug if (json.ToString() == "Success") { //await new MessageDialog("Remove friend OK").ShowAsync(); Singleton.Instance.Current_user.friends.Remove(user); add_friend_btn = Visibility.Visible; remove_friend_btn = Visibility.Collapsed; friends.Remove(Singleton.Instance.Current_user); } else await new MessageDialog("Erreur lors de la suppression de cet ami de votre liste").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de la suppression de cet ami de votre liste").ShowAsync(); }
public async void add_friend() { Exception exception = null; var request = new Http_post(); try { var friend = await Http_get.get_user_by_id(user.id.ToString()); string post_data = "user_id=" + Singleton.Instance.Current_user.id.ToString() + "&friend_id=" + friend.id + "&secureKey=" + await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); var response = await request.post_request("users/addfriend", post_data); var json = JObject.Parse(response).SelectToken("message"); // Debug if (json.ToString() == "Created") { //await new MessageDialog("Add friend OK").ShowAsync(); Singleton.Instance.Current_user.friends.Add(user); add_friend_btn = Visibility.Collapsed; remove_friend_btn = Visibility.Visible; friends.Add(Singleton.Instance.Current_user); } else await new MessageDialog("Erreur lors de l'ajout en ami de cet utilisateur").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de l'ajout en ami de cet utilisateur").ShowAsync(); }
public async void follow() { Exception exception = null; var request = new Http_post(); try { var follow = await Http_get.get_user_by_username(new_follow); string post_data = "user_id=" + Singleton.Instance.Current_user.id.ToString() + "&follow_id=" + follow.id + "&secureKey=" + await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); var response = await request.post_request("users/follow", post_data); var json = JObject.Parse(response).SelectToken("message"); // Debug if (json.ToString() == "Created") { //await new MessageDialog("Follow OK").ShowAsync(); Singleton.Instance.Current_user.follows.Add(follow); follows.Add(follow); } else await new MessageDialog("Erreur lors du follow de cet utilisateur").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors du follow de cet utilisateur").ShowAsync(); }
// SOCIAL LOGIN public async void social_connection(string id, string token, string sn) { Exception exception = null; var request = new Http_post(); try { string social_token = await Security.getSocialToken(id, sn); string encrypted_key = Security.getSocialSecureKey(id, social_token); var response = await request.post_request("social-login", "uid=" + id + "&provider=" + sn + "&encrypted_key=" + encrypted_key + "&token=" + token); var json = JObject.Parse(response).SelectToken("content"); if (json.ToString() != null) { Get_User(response); ((Frame)Window.Current.Content).Navigate(typeof(SoonZik.Views.Home)); } else await new MessageDialog("Erreur lors de la verification de la connexion").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog(exception.Message, "Erreur de connexion via le reseau social").ShowAsync(); }
async public void offer_cart_after_pp_validation(int id) { Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string pack_data = "user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey + "&pack_id=" + pack.id.ToString() + "&amount=" + amount.ToString() + "&artist=" + "65" + //artist.ToString() + "&association=" + "20" + // association.ToString() + "&website=" + "15" + //website.ToString() + "&paypal[payment_id]=" + pp_transac_id + "&gift_user_id=" + id; // HTTP_POST -> URL + DATA var response = await request.post_request("purchases/buypack", pack_data); //var json = JObject.Parse(response).SelectToken("message"); //if (json.ToString() == "Created") //{ await new MessageDialog("Offre du pack validé").ShowAsync(); //} //else // await new MessageDialog("Erreur lors de l'achat du pack").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de l'offre du pack").ShowAsync(); }
async void create_playlist() { Exception exception = null; var request = new Http_post(); try { if (playlist_name == null || playlist_name == "") { await new MessageDialog("Entrez un nom de playlist").ShowAsync(); return; } if (playlist_name.Length < 4) { await new MessageDialog("Le nom de la playlist est trop court").ShowAsync(); return; } string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string data = "user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey + "&playlist[user_id]=" + Singleton.Instance.Current_user.id.ToString() + "&playlist[name]=" + playlist_name; var response = await request.post_request("/playlists/save", data); // to get the id of the new playlist dynamic json = JObject.Parse(response).SelectToken("content"); // get ids string musics_id = ""; //foreach (var music in music_list_to_add) // musics_id += music.id.ToString() + ","; foreach (var music in playlist_update_music) musics_id += music.id.ToString() + ","; var data_update = "user_id=" + Singleton.Instance.Current_user.id + "&secureKey=" + secureKey + "&id=" + json.id + "&playlist[user_id]=" + Singleton.Instance.Current_user.id.ToString() + "&playlist[name]=" + playlist_name + "&playlist[music]=[" + musics_id.Remove(musics_id.Length - 1) + "]"; var response_update = await request.post_request("/playlists/update", data_update); var jsonbis = JObject.Parse(response_update).SelectToken("message"); if (jsonbis.ToString() == "Created") await new MessageDialog("Playlist créée avec succès").ShowAsync(); else await new MessageDialog("Erreur lors de la création de la playlist").ShowAsync(); // clean music list & name music_list_to_add.Clear(); playlist_name = ""; // reload playlist list playlist_update_music.Clear(); playlist_list.Clear(); load_playlist(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de la création de la playlist").ShowAsync(); }
// Method called in SignupCommand file public async void signup() { Exception exception = null; var request = new Http_post(); try { if (passwd != passwd_verif) { await new MessageDialog("Les mots de passe insérés sont différents").ShowAsync(); return; } string date = new_user.birthday_dt.ToString("yyyy-MM-dd"); string user_data = // REQUIRED "&user[username]=" + new_user.username + "&user[email]=" + new_user.email + "&user[password]=" + passwd + "&user[language]=" + "FR" + //"&user[language]=" + new_user.language + //"&user[birthday]=" + new_user.birthday + // OLD DATE "&user[birthday]=" + date + // NOT REQUIRED but are :p "&user[fname]=" + new_user.fname + "&user[lname]=" + new_user.lname + // NOT REQUIRED "&user[phoneNumber]=" + new_user.phoneNumber + "&user[description]=" + new_user.description; // Check if address null if (await check_addr(new_user_addr)) user_data += "&address[numberStreet]=" + new_user_addr.numberStreet + "&address[street]=" + new_user_addr.street + "&address[zipcode]=" + new_user_addr.zipcode + "&address[city]=" + new_user_addr.city + "&address[country]=" + new_user_addr.country + "&address[complement]=" + new_user_addr.complement; else // if the addr is not complete if (check_addr_nb == -1) return; var response = await request.post_request("users/save", user_data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { await new MessageDialog("Inscription réussie").ShowAsync(); ((Frame)Window.Current.Content).Navigate(typeof(SoonZik.Views.Connection)); } else await new MessageDialog("Erreur lors de l'inscription").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de l'inscription").ShowAsync(); }
// public async Task<bool> send_tweets() public async void send_tweets() { Exception exception = null; var request = new Http_post(); try { string secureKey = await Security.getSecureKey(Singleton.Instance.Current_user.id.ToString()); string tweet_data = "tweet[user_id]=" + Singleton.Instance.Current_user.id.ToString() + "&tweet[msg]=" + WebUtility.UrlEncode(message) + "&user_id=" + Singleton.Instance.Current_user.id.ToString() + "&secureKey=" + secureKey; // HTTP_POST -> URL + DATA var response = await request.post_request("tweets/save", tweet_data); var json = JObject.Parse(response).SelectToken("message"); if (json.ToString() == "Created") { Tweet new_tweet = new Tweet(); new_tweet.user = Singleton.Instance.Current_user; new_tweet.msg = message; tweetlist.Insert(0, new_tweet); // new tewwt on top //tweetlist.Add(new_tweet); message = ""; //await new MessageDialog("Tweet SEND").ShowAsync(); //return true; } else await new MessageDialog("Erreur lors de l'envoi du sweet").ShowAsync(); } catch (Exception e) { exception = e; } if (exception != null) await new MessageDialog("Erreur lors de l'envoi du sweet").ShowAsync(); //return false; }