Пример #1
0
        public async Task <QueryResult <JogoCreateViewModel> > CreateJogoAsync(JogoCreateViewModel model)
        {
            var jogo = new JogoResult();

            RestClient  client  = new RestClient(_myGamesAPIConfig.URL);
            RestRequest request = new RestRequest("api/jogo", Method.POST);

            request.AddJsonBody(model);

            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            //System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;

            IRestResponse <string> response = await client.ExecuteAsync <string>(request);

            if (response.StatusCode == System.Net.HttpStatusCode.Created)
            {
                return(new QueryResult <JogoCreateViewModel>
                {
                    Succeeded = true,
                    Result = model,
                    Message = response.Data
                });
            }

            return(new QueryResult <JogoCreateViewModel>
            {
                Succeeded = false,
                Result = model,
                Message = response.Data
            });
        }