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

            if (request.IsSuccessStatusCode)
            {
                return("Registro realizado correctamente");
            }
            return(request.Content.ReadAsStringAsync().Result);
        }
예제 #2
0
        private async void btnAgregarEntorno_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var descripcion = txtDescripcionEntorno.Text;
                var nombre      = txtNombreEntorno.Text;

                Entorno_TR entorno = new Entorno_TR(descripcion, nombre);

                var res = await ComicProcessor.AgregarEntorno(entorno);

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