public async Task <Boolean> UpdateMatch(Tournament tournament, Match match, int phase) { MatchDAO matchDAO = new MatchDAO(match, phase); HttpContent putContent = new StringContent(JObject.FromObject(matchDAO).ToString()); putContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); try { var response = await wc.PutAsync(await ApiAccess.GetRessource(ApiAccess.URL.MATCHS, tournament.Id, match.Id), putContent); GetResponseService.HandleResponse(response, null, false); return(true); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <Boolean> UpdateMatch(Tournament tournament, Match match, int phase) { MatchDAO matchDAO = new MatchDAO(match, phase); HttpContent putContent = new StringContent(JObject.FromObject(matchDAO).ToString()); putContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); var response = await wc.PutAsync(ApiAccess.GetMatchUrl(tournament.Id, match.Id), putContent); String jstr = response.Content.ReadAsStringAsync().Result; if (response.StatusCode == HttpStatusCode.OK) { return(true); } else { return(false); } }
public async Task <bool> AddUser(Account user) { HttpContent postContent = new StringContent(JObject.FromObject(user).ToString()); postContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); try { var response = await wc.PostAsync(await ApiAccess.GetRessource(ApiAccess.URL.ACCOUNT), postContent); GetResponseService.HandleResponse(response, new AccountDAO(), false); } catch (HttpRequestException) { throw new GetDataException(); } return(true); }
public async Task <bool> UpdateAsync(Tournament selectedTournament) { TournamentDAO tournamentDAO = new TournamentDAO(selectedTournament); HttpContent putContent = new StringContent(JObject.FromObject(tournamentDAO).ToString()); putContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); try { var response = await wc.PutAsync(await ApiAccess.GetRessource(ApiAccess.URL.TOURNAMENTS, selectedTournament.Id), putContent); GetResponseService.HandleResponse(response, new TournamentDAO(), false); return(true); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <bool> LogIn(String username, String password) { LogInDAO infoLogin = new LogInDAO(username, password); HttpContent postContent = new StringContent(JObject.FromObject(infoLogin).ToString()); postContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); try { var response = await wc.PostAsync(await ApiAccess.GetRessource(ApiAccess.URL.LOGIN), postContent); LoginResponseDAO responseO = (LoginResponseDAO)GetResponseService.TraiteResponse(response, new LoginResponseDAO(), false); AuthHttpClient.Token = responseO.AccessToken; } catch (HttpRequestException) { throw new GetDataException(); } return(true); }
public async Task <ResponseObject> AddPointMatch(long matchId, Point point) { HttpContent putContent = new StringContent(JObject.FromObject(point).ToString()); putContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); var response = await wc.PostAsync(ApiAccess.GetMatchPointUrl(matchId), putContent); ResponseObject contentResponse = new ResponseObject(); String jstr = response.Content.ReadAsStringAsync().Result; if (response.StatusCode == HttpStatusCode.Created) { contentResponse.Content = JObject.Parse(jstr); contentResponse.Success = true; } else { contentResponse.Content = JArray.Parse(jstr); contentResponse.Success = false; } return(contentResponse); }