async void OnAcceptClicked(object sender, EventArgs args) { var answer = await DisplayAlert("Conferma", "Vuoi accettare l'amicizia?", "Sì", "No"); if (answer) { MobileServiceClient client = new MobileServiceClient(Constants.ApplicationURL); Dictionary <string, string> argoments = new Dictionary <string, string>() { { "idUtente", idUtente.ToString() }, { "idRichiedente", profilo.utente.ID.ToString() }, { "accettata", true.ToString() } }; HttpResponseMessage response = await client.InvokeApiAsync("Friends/RequestResponse", null, HttpMethod.Post, null, argoments); if (response.StatusCode == System.Net.HttpStatusCode.OK) { await DisplayAlert("Avviso", "Amicizia accettata", "Ok"); ListOfFriendsPage.AddAmico(profilo.utente); Dictionary <int, Profilo> req = new Dictionary <int, Profilo>(); richieste.Remove(position); if (richieste.Count != 0) { foreach (var r in richieste) { if (r.Key < position) { req.Add(r.Key, r.Value); } else { req.Add(r.Key - 1, r.Value); } } richieste = req; App.Current.MainPage = new RequestsPage(1, idUtente); } else { HomePage.ResetRequests(); await DisplayAlert("Avviso", "Non hai più richieste pendenti", "Torna alla home"); App.Current.MainPage = new HomePage(); } } else { await DisplayAlert("Attenzione", "Comunicazione col server fallita", "OK"); App.Current.MainPage = new HomePage(); } } }
public HomePage(Profilo pro, string emo, Dictionary <int, Profilo> req, List <Utente> friends, List <Post> posts) { InitializeComponent(); var tapImage = new TapGestureRecognizer(); tapImage.Tapped += OnActionsClicked; imgHome.GestureRecognizers.Add(tapImage); profilo = pro; ModifyPage.SetProfile(profilo); ProfilePage.SetMineProfile(profilo); userBtn.Text = profilo.utente.name + " " + profilo.utente.surname; if (emo != null) { emozione = emo; labelEmo.Text = "Vedo che al momento provi " + emozione; } if (friends != null) { amici = friends; ListOfFriendsPage.SetFriends(amici); ProfilePage.SetFriends(amici); } if (posts != null) { listaPost = posts; BoardPage.SetPosts(listaPost); } ListOfFriendsPage.SetFriends(amici); if (req != null) { richieste = req; RequestsPage.SetRequests(richieste); this.CheckRequests(); } }