public static async Task <string> AgregarServicio(ServicioExtra_TR servicio)
        {
            HttpClient client = new HttpClient
            {
                BaseAddress = new Uri("http://localhost:55979/")
            };
            var request = client.PostAsync("api/Servicio", servicio, new JsonMediaTypeFormatter()).Result;

            if (request.IsSuccessStatusCode)
            {
                return("Registro realizado correctamente");
            }
            return(request.Content.ReadAsStringAsync().Result);
        }
Exemple #2
0
        private async void btnAgregarServicio_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var nombre = txtNombreServicio.Text;

                var descripcion           = txtDescripcionServicio.Text;
                ServicioExtra_TR servicio = new ServicioExtra_TR(nombre, descripcion);

                var res = await ComicProcessor.AgregarServicio(servicio);

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