public async Task<bool> SaveUser(User user) { var json = JsonConvert.SerializeObject(user); HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("api/users", content); if (response.IsSuccessStatusCode) return true; return false; }
public async Task<User> GetUserById(int idUser) { HttpResponseMessage response = await client.GetAsync("api/users/byId/" + idUser); var user = new User(); if (response.IsSuccessStatusCode) { string json = await response.Content.ReadAsStringAsync(); user = JsonConvert.DeserializeObject<User>(json); } return user; }
public void OnNavigatedTo(NavigationEventArgs e) { CurrentUserTeam cut = (CurrentUserTeam)e.Parameter; TeamPlayers tp = cut.CurrentTeamPLayers; currentUser = cut.CurrentUser; _players.Clear(); foreach (var player in tp.players) { _players.Add(player); } }
private async void LoadFavoriteTeams() { currentUser = await daUsers.GetUserById(currentUser.idUser); List<TeamInfo> userTeams = await daTeams.GetUserTeams(currentUser.favoriteteamsusers); teams.Clear(); foreach (var item in userTeams) { teams.Add(item); } }
public void OnNavigatedTo(NavigationEventArgs e) { currentUser = (User)e.Parameter; }
private async void LoadUser(int id) { currentUser = await daUsers.GetUserById(currentUser.idUser); foreach (var item in currentUser.favoriteteamsusers) { if (item.idTeam == _selectedTeam.id) { iconFav.UriSource = new Uri("ms-appx:///Assets/Star-Full.png"); isFavorite = true; } } }
private async void AddRemoveFavorite() { if (NetworkInterface.GetIsNetworkAvailable()) { if (isFavorite) { int idToDelete = 0; foreach (var item in currentUser.favoriteteamsusers) { if (item.idTeam == _selectedTeam.id) idToDelete = item.idFavoriteTeamsUser; } if (await daUsers.RemoveFavoriteTeam(idToDelete)) { iconFav.UriSource = new Uri("ms-appx:///Assets/Star-Empty.png"); isFavorite = false; } } else { if (await daUsers.AddFavoriteTeam(currentUser.idUser, _selectedTeam.id)) { iconFav.UriSource = new Uri("ms-appx:///Assets/Star-Full.png"); isFavorite = true; } } currentUser = await daUsers.GetUserById(currentUser.idUser); } else new MessageDialog(loader.GetString("NoConnection")).ShowAsync(); }
public void OnNavigatedTo(NavigationEventArgs e) { CurrentUserTeam cut = (CurrentUserTeam)e.Parameter; _selectedTeam = cut.CurrentTeam; currentUser = cut.CurrentUser; iconFav = new BitmapImage(new Uri("ms-appx:///Assets/Star-Empty.png")); isFavorite = false; LoadUser(cut.CurrentUser.idUser); foreach (var item in currentUser.favoriteteamsusers) { if (item.idTeam == _selectedTeam.id) { iconFav = new BitmapImage(new Uri("ms-appx:///Assets/Star-Full.png")); isFavorite = true; } } if (_selectedTeam.crestUrl.EndsWith("svg")) { webViewVisibility = "Visible"; imageVisibility = "Collapsed"; } else { webViewVisibility = "Collapsed"; imageVisibility = "Visible"; } }
public void OnNavigatedTo(User parameter) { currentUser = parameter; }
public async void GoToTeam(string href) { if (NetworkInterface.GetIsNetworkAvailable()) { currentUser = await daUsers.GetUserById(currentUser.idUser); CurrentUserTeam cut = new CurrentUserTeam(); cut.CurrentTeam = await daTeams.GetTeamByLink(href); cut.CurrentUser = currentUser; _navigationService.NavigateTo("TeamPage", cut); } else new MessageDialog(loader.GetString("NoConnection")).ShowAsync(); }
public void OnNavigatedTo(NavigationEventArgs e) { CurrentUserTeam cut = (CurrentUserTeam)e.Parameter; currentUser = cut.CurrentUser; LoadTeams(cut.Tag); }
private void GoToHome(User item) { var settings = Windows.Storage.ApplicationData.Current.LocalSettings; settings.Values["login"] = login; settings.Values["password"] = password; //isLoading = false; _navigationService.NavigateTo("HomePage", item); }
private async void SaveUser() { User user = new User() { login = login, password = password }; user.password = PasswordEncryption.cryptPwd(user.password); if (await da.SaveUser(user)) _navigationService.GoBack(); else new MessageDialog(loader.GetString("RegistrationError")).ShowAsync(); }
public void OnNavigatedTo(User parameter) { currentUser = parameter; LoadFavoriteTeams(); }
private async void LoadUser() { currentUser = await daUsers.GetUserById(currentUser.idUser); }