public async Task <List <PlayerDTO> > GetPlayersAsync() { using (HttpClient httpClient = new HttpClient()) { return(JsonConvert.DeserializeObject <List <PlayerDTO> >( await httpClient.GetStringAsync(URIService.Build(Get)) )); } }
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))); } }
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)) )); } }
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)); } }
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() )); } }