Ejemplo n.º 1
0
        public static async Task SendSurvei(SurveiResponse surveiResponse)
        {
            using (var _client = GetClient())
            {
                var uri  = new Uri("https://api.delighted.com/v1/survey_responses.json");
                var json = JsonConvert.SerializeObject(surveiResponse, new JsonSerializerSettings
                {
                    ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                    NullValueHandling = NullValueHandling.Ignore
                });
                var content = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage response = null;
                response = await _client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    System.Diagnostics.Debug.WriteLine(@"\tSend survei successfully saved.");
                }
            }
        }
        private async void btnEnviar_Clicked(object sender, EventArgs e)
        {
            var people = new People
            {
                Name  = "Darlan Silva 2",
                Email = "*****@*****.**"
            };

            people = await RestService.CreateOrUpdatePerson(people);

            var survei = new SurveiResponse
            {
                Comment = this.edtComentario.Text,
                Score   = this._score,
                Person  = people.ID
            };
            await RestService.SendSurvei(survei);

            PopupNavigation.Instance.PopAllAsync();
            await PopupNavigation.PushAsync(new PopupFeedbackView());
        }