Esempio n. 1
0
        private async void CreateMatches(MatchGenerate matchObj)
        {
            HttpClient client = new HttpClient();
            string     json   = JsonConvert.SerializeObject(matchObj);

            client.DefaultRequestHeaders.Add("Authorization", Authentication.token.Token);
            var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync(BASE_URL + "api/matches/generate", httpContent);

            Debug.WriteLine(response.Content);
        }
Esempio n. 2
0
        public HttpResponseMessage GenerateMatches([FromBody] MatchGenerate MatchObj)
        {
            //if (Authentication.getInstance().isAuthenticateWithHeader(Request))
            //{
            IMatchDao MatchDao = DalFactory.CreateMatchDao(database);
            ObservableCollection <Match> matchList;

            matchList = BLMatch.GenerateMatches(MatchObj.NumberOfMatches, MatchObj.chosenPlayers, MatchObj.tournamentId);
            if (BLMatch.insertMatches(matchList))
            {
                return(Request.CreateResponse <ObservableCollection <Match> >(HttpStatusCode.OK, matchList));
            }
            return(Request.CreateResponse(HttpStatusCode.Conflict));
            //}
            //else
            //{
            //	return Request.CreateResponse(HttpStatusCode.Forbidden);
            //}
        }