protected override async void OnNavigatedTo(NavigationEventArgs e) { string parameter; if (NavigationContext.QueryString.TryGetValue("user", out parameter)) { if (parameter == WeBallAPI.currentUser._id) { FirstNamePrompt.Text = WeBallAPI.currentUser.fullName; profileStack.DataContext = WeBallAPI.currentUser; } else { await WeBallAPI.getUser(parameter); addFriend.Opacity = 100; addFriend.IsEnabled = true; if (WeBallAPI.Success == false) { return; } /* if (WeBallAPI.profileUser.relationStatus.isRelation == 0) * { * addFriend.Opacity = 100; * GridAdd.Background = new SolidColorBrush(Colors.Orange); * } * else if (WeBallAPI.profileUser.relationStatus.isRelation == 2) * { * addFriend.Opacity = 100; * GridAdd.Background = new SolidColorBrush(Colors.Green); * } * else * { * addFriend.Opacity = 100; * addFriend.IsEnabled = true; * }*/ FirstNamePrompt.Text = WeBallAPI.profileUser.fullName; profileStack.DataContext = WeBallAPI.profileUser; } } else { await WeBallAPI.me(); if (WeBallAPI.Success == false) { return; } FirstNamePrompt.Text = WeBallAPI.currentUser.fullName; profileStack.DataContext = WeBallAPI.currentUser; } }
private async void buttonLogin_Click(object sender, RoutedEventArgs e) { await tryLogin(sender, e); if (WeBallAPI.Success == false) { return; } await WeBallAPI.me(); if (WeBallAPI.Success == false) { return; } System.Diagnostics.Debug.WriteLine("Logging in"); if (!string.IsNullOrEmpty(WeBallAPI.Token)) { try { await WeBallAPI.updatePos(); } catch (Exception exception) { MessageBoxResult result = MessageBox.Show("Problème de localisation, vérifiez vos paramètres.", "Location", MessageBoxButton.OK); return; } System.Diagnostics.Debug.WriteLine("get Fives"); await WeBallAPI.getFives(); if (WeBallAPI.Success == false) { return; } NavigationService.Navigate(new Uri("/ProfilePage.xaml", UriKind.Relative)); } else { System.Diagnostics.Debug.WriteLine("Problem"); } }