private void WithDraw(object sender, EventArgs e) { if (_atm.Balance < _view.WithDrawSum) { _view.ShowMessage("Недостаточно средств!", "Ошибка!"); return; } if (_view.WithDrawSum == 0) { _view.ShowMessage("Введите сумму изъятия!", "Ошибка!"); return; } var result = _atm.CalculateWithDraw(_view.WithDrawSum, _view.PreferNominal); var withDrawAmount = 0; var sb = new StringBuilder(); foreach (var pair in result) { sb.Append($"{pair.Key}р.: {pair.Value}шт, "); withDrawAmount += pair.Key * pair.Value; } sb.Append($"Выдано : {withDrawAmount}"); _atm.Balance -= withDrawAmount; _view.ShowBalance(_atm.Balance); _view.UpdateAtmLoading(_atm.AtmCurrentLoad, _atm.MaxBankNotesCapacity); _view.ShowMessage(sb.ToString(), "Готово"); }