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 <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 <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 <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 <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 <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); }