コード例 #1
0
 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;
 } 
コード例 #2
0
 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;
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 public void OnNavigatedTo(NavigationEventArgs e)
 {
     currentUser = (User)e.Parameter;
 }
コード例 #6
0
        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;
                }
            }
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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";
            }
        }
コード例 #9
0
 public void OnNavigatedTo(User parameter)
 {
     currentUser = parameter;
 }
コード例 #10
0
        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();
        }
コード例 #11
0
 public void OnNavigatedTo(NavigationEventArgs e)
 {
     CurrentUserTeam cut = (CurrentUserTeam)e.Parameter;
     currentUser = cut.CurrentUser;
     LoadTeams(cut.Tag);
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 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();
 }
コード例 #14
0
 public void OnNavigatedTo(User parameter)
 {
     currentUser = parameter;
     LoadFavoriteTeams();
 }
コード例 #15
0
 private async void LoadUser()
 {
     currentUser = await daUsers.GetUserById(currentUser.idUser);
 }