public AddMonkeyPageViewModel(INavigation navigation) { Photo = DefaultPhoto; var dataManager = App.MonkeyDataManager; PickPhotoCommand = new Command(async() => { image = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(); if (image != null) { Photo = ImageSource.FromFile(image.Path); } }); UploadPhotoCommand = new Command(async() => { if (!string.IsNullOrEmpty(Status) && image != null) { var monkey = new Models.Monkey { Status = this.Status, UserName = App.UserName }; await dataManager.SaveMonkeyAsync(monkey); await dataManager.AddImage(monkey, image.Path); if (navigation != null) { await navigation.PopAsync(); } } }); }
public AddMonkeyPageViewModel(INavigation navigation) { Photo = DefaultPhoto; var dataManager = App.MonkeyDataManager; PickPhotoCommand = new Command(async () => { image = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(); if(image!=null) Photo = ImageSource.FromFile(image.Path); }); UploadPhotoCommand = new Command(async ()=> { if (!string.IsNullOrEmpty(Status) && image != null) { var monkey = new Models.Monkey { Status = this.Status, UserName= App.UserName }; await dataManager.SaveMonkeyAsync(monkey); await dataManager.AddImage(monkey, image.Path); if (navigation != null) await navigation.PopAsync(); } }); }