public async Task <ActionResult> Deposit(WithDrawModel model) { if (!ModelState.IsValid) { return(View(model)); } MakeTransaction(model.Amount, "Deposit", recesiver: GetAccount().Id); await UpdateAmount(model.Amount, "this", true); return(RedirectToAction("Index", "Account")); }
public async Task <ActionResult> Withdraw(WithDrawModel model) { if (model.Amount > GetAccount().Balance) { ModelState.AddModelError(string.Empty, "Podałeś kwotę większą niż posiadasz na koncie"); } if (!ModelState.IsValid) { return(View(model)); } MakeTransaction(model.Amount, "Withdraw", sender: GetAccount().Id); await UpdateAmount(model.Amount, "this", false); return(RedirectToAction("Index", "Account")); }
private void Save(object sender, RoutedEventArgs e) { if (cb_clients.SelectedIndex == -1) { return; } WithDrawModel withdraw = new WithDrawModel() { MovieTitle = Movie.MovieModel.Title, ClientId = (cb_clients.SelectedItem as ClientModel).Id, Employee = Employee.Id, WithDrawReturn = (DateTime)dt_returndate.SelectedDate, WithDrawDate = DateTime.Today }; if (Movie.MovieModel.Units < 1) { MessageBox.Show("Não existem unidades disponíveis para este filme!", "Falta de unidades", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (WithDrawModel.Save(withdraw)) { // Decrementa unidades disponíveis do filme Movie.MovieModel.Units--; // Realiza update do filme com as unidades novas MovieModel.Replace(Movie.MovieModel); MovieStoreManager.Movies = MovieStoreManager.GetAllMovies(); MessageBox.Show("Retirada bem sucessida!"); txt_units.Text = Movie.MovieModel.Units.ToString(); ClearTxts(); UpdateTable(); } else { MessageBox.Show("Erro ao tentar retirar filme! Tente novamente."); } }