async void AddPhoto(object obj) { try { // выбор фото var photopath = ""; Image img = new Image(); if (CrossMedia.Current.IsPickPhotoSupported) { MediaFile photo = await CrossMedia.Current.PickPhotoAsync(); photopath = photo.Path; } Photo c = new Photo() { Id = ++lastId, AddedDate = DateTime.Now, ClientPhoto = File.ReadAllBytes(photopath) }; Photos.Add(c); await PhotoLoader.AddPhoto(c); } catch { } }
async void AddPhoto(object obj) { try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.ShowDialog(); var path = openFileDialog.FileName; Photo c = new Photo() { Id = ++lastId, AddedDate = DateTime.Now, ClientPhoto = File.ReadAllBytes(path) }; Photos.Add(c); await PhotoLoader.AddPhoto(c); } catch { MessageBox.Show("Oops."); } }