Exemplo n.º 1
0
        public static async Task <bool> AddGame(UserGame userGame)
        {
            using (HttpClient client = new HttpClient())
            {
                var json     = JsonConvert.SerializeObject(userGame);
                var content  = new StringContent(json, Encoding.UTF8, "application/json");
                var response = await client.PostAsync("https://collectorgameapp.azurewebsites.net/api/Users", content);

                return(response.IsSuccessStatusCode);
            }
        }
Exemplo n.º 2
0
        public static async Task <bool> EditGameList(int id, UserGame userGame)
        {
            using (HttpClient client = new HttpClient())
            {
                var json     = JsonConvert.SerializeObject(userGame);
                var content  = new StringContent(json, Encoding.UTF8, "application/json");
                var response = await client.PutAsync(String.Concat(
                                                         "https://collectorgameapp.azurewebsites.net/ChangeList/", id), content);

                return(response.IsSuccessStatusCode);
            }
        }
Exemplo n.º 3
0
        public static async Task <IEnumerable <UserDlc> > GetMyDlcFromList(UserGame selectedGame)
        {
            using (HttpClient client = new HttpClient())
            {
                ObservableCollection <UserDlc> MyGames = new ObservableCollection <UserDlc>();
                var response = await client.GetStringAsync("https://collectorgameapp.azurewebsites.net/api/Users");

                var games = JsonConvert.DeserializeObject <List <UserGame> >(response);
                foreach (var game in games)
                {
                    if (game.UserTitle.Equals(selectedGame.UserTitle))
                    {
                        foreach (var dlc in game.UserDlcs)
                        {
                            MyGames.Add(dlc);
                        }
                        break;
                    }
                }
                return(MyGames);
            }
        }