private async Task ExecuteSaveRatingCommand() { try { AddRatingCommand.ChangeCanExecute(); var rating = new Rating() { CheeseId = RatingToAdd.CheeseId, DateRated = DateTime.Now, Notes = RatingToAdd.Notes, WedgeRating = RatingToAdd.WedgeRating, PhotoUrl = RatingToAdd.PhotoUrl ?? string.Empty, AudioUrl = RatingToAdd.AudioUrl ?? string.Empty }; rating = await _dataService.RateCheeseAsync(rating); RatingToAdd.RatingId = rating.RatingId; Device.BeginInvokeOnMainThread(async() => await Page.Navigation.PopModalAsync(true)); } catch (NoInternetException) { await Page.DisplayAlert("No Internet!", "Cannot Access The Internet!", "Darn!"); } finally { AddRatingCommand.ChangeCanExecute(); } }
private async Task ExecuteAddCheeseCommand() { try { AddCheeseCommand.ChangeCanExecute(); var newCheese = new Cheese() { CheeseName = CheeseToAdd.CheeseName, DairyName = CheeseToAdd.DairyName, DateAdded = DateTime.Now }; newCheese = await _dataService.AddCheeseAsync(newCheese).ConfigureAwait(false); var newRating = new Rating() { CheeseId = newCheese.CheeseId, Notes = CheeseToAdd.Notes, WedgeRating = CheeseToAdd.WedgeRating, DateRated = DateTime.Now }; newRating = await _dataService.RateCheeseAsync(newRating); CheeseToAdd.CheeseId = newRating.CheeseId; CheeseToAdd.RatingId = newRating.RatingId; Device.BeginInvokeOnMainThread(async() => { await Page.Navigation.PopModalAsync(true); }); } catch (NoInternetException) { await Page.DisplayAlert("No Internet!", "Cannot Access The Internet!", "Darn!"); } finally { AddCheeseCommand.ChangeCanExecute(); } }