private async void btnAceptar(object sender, RoutedEventArgs e) { if (file != null) { var stream = await file.OpenAsync(FileAccessMode.Read); ParseFile fileP = new ParseFile(file.Name, stream.AsStream()); await fileP.SaveAsync(); FotoMascota foto = new FotoMascota(); foto.Url = fileP.Url.OriginalString; foto.IdMascota = mascota.Id; var imagenMascota = new ParseObject(FotoMascota.TABLA) { { FotoMascota.IDMASCOTA, mascota.Id }, { FotoMascota.IMAGEN, fileP }, }; await imagenMascota.SaveAsync(); foto.Id = imagenMascota.ObjectId; mascota.Fotos.Add(foto); rootFrame.GoBack(); } else { var dlg = new Windows.UI.Popups.MessageDialog("Debe seleccionar una imagen."); await dlg.ShowAsync(); } }
private async void btnAceptar(object sender, RoutedEventArgs e) { if (file != null && nombre.Text != "" && descripcion.Text != "") { var stream = await file.OpenAsync(FileAccessMode.Read); ParseFile fileP = new ParseFile(file.Name, stream.AsStream()); await fileP.SaveAsync(); ObservableCollection <FotoMascota> fotos = new ObservableCollection <FotoMascota>(); Mascota mascota = new Mascota(); FotoMascota foto = new FotoMascota(); foto.Url = fileP.Url.OriginalString; mascota.Nombre = nombre.Text; mascota.Tipo = tipomascota; mascota.NombreUsuario = ParseUser.CurrentUser.Username; mascota.Descripcion = descripcion.Text; mascota.Edad = comboEdad.SelectedItem as string; if (descripcion.Text.Length > 45) { mascota.DescripcionCorta = descripcion.Text.Substring(0, 45); } else { mascota.DescripcionCorta = descripcion.Text; } var parseMascota = new ParseObject(Mascota.TABLA) { { Mascota.TIPO, tipomascota }, { Mascota.NOMBRE, nombre.Text }, { Mascota.NOMBREUSUARIO, ParseUser.CurrentUser.Username }, { Mascota.DESCRIPCION, descripcion.Text }, { Mascota.EDAD, comboEdad.SelectedItem }, }; await parseMascota.SaveAsync(); mascota.Id = parseMascota.ObjectId; foto.IdMascota = parseMascota.ObjectId; var imagenMascota = new ParseObject(FotoMascota.TABLA) { { FotoMascota.IDMASCOTA, parseMascota.ObjectId }, { FotoMascota.IMAGEN, fileP }, }; await imagenMascota.SaveAsync(); foto.Id = imagenMascota.ObjectId; fotos.Add(foto); mascota.Fotos = fotos; principalPage.notificarSeAgregoLaMascota(mascota); rootFrame.GoBack(); } else { var dlg = new Windows.UI.Popups.MessageDialog("Por favor ingrese todos los campos."); await dlg.ShowAsync(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { FotoMascota foto = e.Parameter as FotoMascota; ImageBrush brush = new ImageBrush(); brush.Stretch = Stretch.Uniform; BitmapImage image = new BitmapImage(new Uri(foto.Url)); brush.ImageSource = image; imagenMascota.Fill = brush; }
private async void loadDataAdultos() { var query = ParseObject.GetQuery(Mascota.TABLA) .WhereEqualTo(Mascota.TIPO, "Adultos") .WhereEqualTo("username", ParseUser.CurrentUser.Username); IEnumerable <ParseObject> results = await query.FindAsync(); foreach (ParseObject parseObject in results) { Mascota mascota = new Mascota(); var queryfoto = ParseObject.GetQuery(FotoMascota.TABLA) .WhereEqualTo(FotoMascota.IDMASCOTA, parseObject.ObjectId); IEnumerable <ParseObject> fotos = await queryfoto.FindAsync(); ObservableCollection <FotoMascota> fotosMascotas = new ObservableCollection <FotoMascota>(); foreach (ParseObject foto in fotos) { FotoMascota fotoMascota = new FotoMascota(); fotoMascota.Id = foto.ObjectId; fotoMascota.IdMascota = (string)foto[FotoMascota.IDMASCOTA]; fotoMascota.Url = foto.Get <ParseFile>(FotoMascota.IMAGEN).Url.OriginalString; fotosMascotas.Add(fotoMascota); } mascota.Nombre = (String)parseObject[Mascota.NOMBRE]; mascota.Tipo = (string)parseObject[Mascota.TIPO]; mascota.NombreUsuario = (string)parseObject[Mascota.NOMBREUSUARIO]; mascota.Id = parseObject.ObjectId; mascota.Descripcion = (string)parseObject[Mascota.DESCRIPCION]; if (mascota.Descripcion.Length > 45) { mascota.DescripcionCorta = mascota.Descripcion.Substring(0, 45) + " . . . ."; } else { mascota.DescripcionCorta = mascota.Descripcion; } mascota.Edad = (string)parseObject[Mascota.EDAD] + " años"; mascota.Fotos = fotosMascotas; mascotasAdultos.Add(mascota); } }