Exemplo n.º 1
0
        private async void _btnGuardar_Click(object sender, EventArgs e)
        {
            if (!CamposInvalidos())
            {
                try
                {
                    var servicio = new Servicio()
                    {
                        Nombre    = _nombre.Text,
                        Monto     = Convert.ToDouble(_monto.Text),
                        EsPorMes  = _tipoPago.SelectedItem.ToString().ToLower().Equals("mensualmente") ? true : false,
                        FechaPago = Convert.ToDateTime(_fechaPago.Text)
                    };

                    await servicioService.AgregarServicio(servicio);

                    Toast.MakeText(this.Activity, "Servicio agregado correctamente", ToastLength.Long).Show();
                }
                catch
                {
                    Toast.MakeText(this.Activity, "Hubo un problema al tratar de agregar el servicio. Intente de nuevo mas tarde.", ToastLength.Long).Show();
                }
                finally
                {
                    LimpiarCampos();
                }
            }
        }