Ejemplo n.º 1
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     try
     {
         editor                = (EditorDePerritos)e.Parameter;
         m                     = editor.mascota;
         user                  = editor.user;
         nombreBox.Text        = m.nombre;
         descripcionBox.Text   = m.descripcion;
         edadBox.Text          = m.edad.ToString();
         tipoBox.SelectedIndex = m.tipo - 1;
         btnPhoto.Visibility   = Visibility.Collapsed;
         edita                 = true;
     }
     catch
     {
         user = (Usuario)e.Parameter;
     }
     conMas = new ConectorMascota(user);
 }
Ejemplo n.º 2
0
        private async void listaTapped(object sender, TappedRoutedEventArgs e)
        {
            MascotaAdapter ma = new MascotaAdapter();
            Mascota        m  = new Mascota();
            var            s  = (FrameworkElement)sender;
            var            d  = s.DataContext;

            ma = (MascotaAdapter)d;
            m  = await conMas.ObtenerID(ma.id);

            //m = (Mascota)e.Handled;
            if (userBox.SelectedItem.Equals("ADOPTADOS"))
            {
                //que hacer si el usuario mantiene presionado un perro mientras mira la lista de perros que adopto
                ContentDialog ventanita = new ContentDialog()
                {
                    Title               = "Cancelar adopcion",
                    Content             = "¿Poner nuevamente en adopcion la mascota?",
                    PrimaryButtonText   = "CONFIRMAR",
                    SecondaryButtonText = "CANCELAR"
                };
                ContentDialogResult result = await ventanita.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    MascotaAdapter.mascotaAdapter.Remove(ma);
                    m = await conMas.ObtenerID(ma.id);

                    m.estado     = Mascota.ESTADO_PUBLICADO;
                    m.user_adopt = 0;
                    conMas.editarMascota(m);
                    lista.ItemsSource = MascotaAdapter.mascotaAdapter;
                }
            }
            else if (userBox.SelectedItem.Equals("SUBIDOS"))
            {
                //que hacer si el usuario mantiene presionado un item mientras mira la lista de perros que subio
                ContentDialog ventanita = new ContentDialog()
                {
                    Title               = "Confirmar accion",
                    Content             = "Elija que desea hacer con esta mascota",
                    PrimaryButtonText   = "EDITAR",
                    SecondaryButtonText = "BORRAR"
                };
                ContentDialogResult result = await ventanita.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    EditorDePerritos editor = new EditorDePerritos();
                    editor.mascota = m;
                    editor.user    = usuario;
                    Frame.Navigate(typeof(PerritoNuevo), editor);
                }
                else
                {
                    MascotaAdapter.mascotaAdapter.Remove(ma);
                    conMas.eliminarMascota(m);
                    lista.ItemsSource = MascotaAdapter.mascotaAdapter;
                }
            }
            else
            {
                //que hacer si el usuario mantiene presionado un item mientras mira la lista de perros en adopcion
                ContentDialog ventanita = new ContentDialog()
                {
                    Title               = "Confirmar adopcion",
                    Content             = "¿Queres adoptar a esta mascota?",
                    PrimaryButtonText   = "ADOPTAR",
                    SecondaryButtonText = "CANCELAR"
                };
                ContentDialogResult result = await ventanita.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    conMas.adoptarMascota(m);
                    MascotaAdapter.mascotaAdapter.Remove(ma);
                    lista.ItemsSource = MascotaAdapter.mascotaAdapter;
                }
            }
        }