예제 #1
0
 public async Task <List <PlayerDTO> > GetPlayersAsync()
 {
     using (HttpClient httpClient = new HttpClient()) {
         return(JsonConvert.DeserializeObject <List <PlayerDTO> >(
                    await httpClient.GetStringAsync(URIService.Build(Get))
                    ));
     }
 }
예제 #2
0
        public async Task <HttpResponseMessage> DeleteMatch(int id)
        {
            string URI = Delete.Replace("{id}", Convert.ToString(id));

            using (HttpClient httpClient = new HttpClient())
            {
                return(await httpClient.DeleteAsync(URIService.Build(URI)));
            }
        }
예제 #3
0
        public async Task <List <MatchDTO> > GetStats(int id)
        {
            string URI = GetId.Replace("{id}", Convert.ToString(id));

            using (HttpClient httpClient = new HttpClient())
            {
                return(JsonConvert.DeserializeObject <List <MatchDTO> >(
                           await httpClient.GetStringAsync(URIService.Build(URI))
                           ));
            }
        }
예제 #4
0
        public async Task <HttpResponseMessage> UpdateMatch(MatchDTO matchDTO)
        {
            string        URI  = Put.Replace("{id}", Convert.ToString(matchDTO.Id));
            StringContent json = new StringContent(JsonConvert.SerializeObject(matchDTO),
                                                   Encoding.UTF8, "text/json");

            using (HttpClient httpClient = new HttpClient())
            {
                return(await httpClient.PutAsync(URIService.Build(URI), json));
            }
        }
예제 #5
0
        public async Task <MatchDTO> AddMatch(MatchDTO matchDTO)
        {
            StringContent json = new StringContent(JsonConvert.SerializeObject(matchDTO),
                                                   Encoding.UTF8, "text/json");

            using (HttpClient httpClient = new HttpClient())
            {
                HttpResponseMessage message = await httpClient.PostAsync(URIService.Build(Post), json);

                return(JsonConvert.DeserializeObject <MatchDTO>(
                           await message.Content.ReadAsStringAsync()
                           ));
            }
        }