private async void Buy(object sender, EventArgs e) { Account account = main.GetAccount; int sum = 0; foreach (var item in main.GetBasketMovies) { sum += item.Price; } var answer = await DisplayAlert("Уведомление", "Вы уверены что хотите купить фильмы", "Да", "Нет"); if (answer) { if (account.Money >= sum) { account.Money -= sum; main.GetAccount = account; await App.DBAccount.EditItemAsync(account); List <BuyMovie> buyMovies = new List <BuyMovie>(); foreach (var item in main.GetBasketMovies) { BuyMovie buy = new BuyMovie { IdAccount = account.IdAccount, IdMovie = item.IdMovie, DateBuy = DateTime.Now }; buyMovies.Add(buy); } await App.DBBuyMovie.SaveItemsAsync(buyMovies); main.GetBasketMovies.Clear(); list.ItemsSource = null; (main.Detail as NavigationPage).PushAsync(new PanelListMovie(main)); main.Master = new UserPanelMaster(main) { Title = "Панель пользователя", BindingContext = account }; } else { await DisplayAlert("Уведомление", "На вашем аккаунте не хватает денег", "Окей"); } } }
public Task <int> EditItemAsync(BuyMovie item) { return(_database.UpdateAsync(item)); }
public Task <int> DeleteItemAsync(BuyMovie item) { return(_database.DeleteAsync(item)); }
public Task <int> SaveItemAsync(BuyMovie item) { return(_database.InsertAsync(item)); }