コード例 #1
0
        public async Task <ResponseObject> AddTournamentAsync(Tournament tournament)
        {
            TournamentListDAO tournamentListDAO = new TournamentListDAO(tournament);
            HttpContent       postContent       = new StringContent(JObject.FromObject(tournamentListDAO).ToString());

            postContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var wc       = new AuthHttpClient();
            var response = await wc.PostAsync(new Uri(ApiAccess.TournamentUrl), postContent);

            return(GetResponseService.TraiteResponse(response, new TournamentDAO(), false));
        }
コード例 #2
0
        public async Task <bool> AddTournamentAsync(Tournament tournament)
        {
            TournamentListDAO tournamentListDAO = new TournamentListDAO(tournament);
            HttpContent       postContent       = new StringContent(JObject.FromObject(tournamentListDAO).ToString());

            postContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var wc = new AuthHttpClient();

            try
            {
                var response = await wc.PostAsync(await ApiAccess.GetRessource(ApiAccess.URL.TOURNAMENTS), postContent);

                GetResponseService.HandleResponse(response, new TournamentDAO(), false);
                return(true);
            }
            catch (HttpRequestException)
            {
                throw new GetDataException();
            }
        }