public async Task <ResponseObject> GetParticipants(long idTournament) { var wc = new AuthHttpClient(); var reponse = await wc.GetAsync(new Uri(ApiAccess.TournamentUrl + "/" + idTournament + "/participants")); return(GetResponseService.TraiteResponse(reponse, new UserDAO(), true)); }
public async Task <ResponseObject> GetTournament(long idTournament) { var wc = new AuthHttpClient(); var reponse = await wc.GetAsync(new Uri(ApiAccess.TournamentUrl + "/" + idTournament )); return(GetResponseService.TraiteResponse(reponse, new TournamentDAO(), false)); }
public async Task <ResponseObject> GetTournaments() { var wc = new AuthHttpClient(); var reponse = await wc.GetAsync(new Uri(ApiAccess.TournamentUrl)); return(GetResponseService.TraiteResponse(reponse, new TournamentListDAO(), true)); }
public async Task <ResponseObject> AddMatch(Tournament tournament, Match match, int phase) { if (phase <= 0) { phase = 1; } 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.PostAsync(ApiAccess.GetMatchUrl(tournament.Id, match.Id), 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); }
public async Task <ResponseObject> GetUsersWithAccount() { var wc = new AuthHttpClient(); var reponse = await wc.GetAsync(new Uri(ApiAccess.UsersAccountUrl)); return(GetResponseService.TraiteResponse(reponse, new UserDAO(), true)); }
public async Task <ResponseObject> GetClubs() { var wc = new AuthHttpClient(); var response = await wc.GetAsync(new Uri(ApiAccess.ClubUrl)); var reponse = GetResponseService.TraiteResponse(response, new ClubDAO(), true); return(reponse); }
public async Task <ResponseObject> AddClub(Club club) { HttpContent postContent = new StringContent(JObject.FromObject(club).ToString()); postContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); var response = await wc.PostAsync(new Uri(ApiAccess.ClubUrl), postContent); return(GetResponseService.TraiteResponse(response, new ClubDAO(), false)); }
public async Task <ResponseObject> 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(); var response = await wc.PutAsync(new Uri(ApiAccess.TournamentUrl + "/" + selectedTournament.Id), putContent); return(GetResponseService.TraiteResponse(response, new TournamentDAO(), false)); }
public async Task <Tournament> GetTournament(long idTournament) { var wc = new AuthHttpClient(); try { var reponse = await wc.GetAsync(await ApiAccess.GetRessource(ApiAccess.URL.TOURNAMENTS, idTournament)); return((Tournament)GetResponseService.HandleResponse(reponse, new TournamentDAO(), false)); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <List <Tournament> > GetTournaments() { var wc = new AuthHttpClient(); try { var reponse = await wc.GetAsync(await ApiAccess.GetRessource(ApiAccess.URL.TOURNAMENTS)); var tournamentDAO = GetResponseService.HandleResponse(reponse, new TournamentListDAO(), true); return(((List <Object>)tournamentDAO).Cast <Tournament>().ToList()); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <List <User> > GetUsersWithAccount() { var wc = new AuthHttpClient(); try { var reponse = await wc.GetAsync(await ApiAccess.GetRessource(ApiAccess.URL.USER_ACCOUNT)); var usersDAO = GetResponseService.TraiteResponse(reponse, new UserDAO(), true); return(((List <object>)usersDAO).Cast <User>().ToList()); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <List <User> > GetParticipants(long idTournament) { var wc = new AuthHttpClient(); try { var reponse = await wc.GetAsync(await ApiAccess.GetRessource(ApiAccess.URL.PARTICIPANTS, idTournament)); var usersDao = GetResponseService.HandleResponse(reponse, new UserDAO(), true); return(((List <Object>)usersDao).Cast <User>().ToList()); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <bool> DeletaMatchAsync(long idTournament, Match m) { var wc = new AuthHttpClient(); try { var response = await wc.DeleteAsync(await ApiAccess.GetRessource(ApiAccess.URL.MATCHS, idTournament, m.Id)); GetResponseService.TraiteResponse(response, null, false); return(true); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <List <Club> > GetClubs() { var wc = new AuthHttpClient(); try { var response = await wc.GetAsync(await ApiAccess.GetRessource(ApiAccess.URL.CLUBS)); var clubsDao = GetResponseService.HandleResponse(response, new ClubDAO(), true); return(((List <object>)clubsDao).Cast <Club>().ToList()); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <ResponseObject> 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(); var response = await wc.PostAsync(new Uri(ApiAccess.LogInUrl), postContent); ResponseObject responseO = GetResponseService.TraiteResponse(response, new LoginResponseDAO(), false); if (responseO.Success) { ApiAccess.Instance.Token = ((LoginResponseDAO)responseO.Content).AccessToken; } return(responseO); }
public async Task <bool> AddUser(User 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.USERS), postContent); GetResponseService.TraiteResponse(response, new UserDAO(), false); return(true); } catch (HttpRequestException) { throw new GetDataException(); } }
public async Task <bool> AddPointMatch(long matchId, Point point) { HttpContent putContent = new StringContent(JObject.FromObject(point).ToString()); putContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var wc = new AuthHttpClient(); try { var response = await wc.PostAsync(await ApiAccess.GetRessource(ApiAccess.URL.POINTS, matchId), 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(); 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> 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); }