コード例 #1
0
        public static async Task <string> AgregarTour(Tour_TR tour)
        {
            HttpClient client = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:55979/")
            };
            var request = client.PostAsync("api/Tour", tour, new JsonMediaTypeFormatter()).Result;

            if (request.IsSuccessStatusCode)
            {
                return("Registro realizado correctamente");
            }
            return(request.Content.ReadAsStringAsync().Result);
        }
コード例 #2
0
        private async void btnAgregarTour_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var valor      = Decimal.Parse(txtValorTour.Text);
                var itinerario = txtItinerarioTour.Text;
                var nombre     = txtNombreTour.Text;

                Tour_TR tour = new Tour_TR(valor, itinerario, nombre);

                var res = await ComicProcessor.AgregarTour(tour);

                if (res != String.Empty)
                {
                    MessageBox.Show(res.ToString());
                }
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.ToString());
            }
        }