/// <summary> /// Buy the Ticket and pay up /// Shows MessageBox with the selected tickets and calculates the change money /// </summary> private void PayUp() { var change = EnteredMoneyTotal - TotalPrice; if (change >= 0) { StringBuilder message = new StringBuilder(); message.AppendLine("Folgende Fahrscheine gekauft: "); ShoppingCart.ToList().ForEach(ticket => message.AppendLine($"- {ticket.Amount}x {ticket.TicketName}")); message.AppendLine(); message.AppendLine($"Wechselgeld: {change:0.00}€"); message.AppendLine(GetStringFromMoneyList(CalculateChange())); MessageBox.Show(message.ToString(), "Nett mit dir Geschäfte zu machen :)", MessageBoxButton.OK, MessageBoxImage.Information); EnteredMoneyBits.Clear(); ShoppingCart.ToList().ForEach(ticket => ticket.Amount = 0); ShoppingCart.Clear(); RefillShoppingCart(); RaisePropertyChanged(nameof(TotalPrice)); RaisePropertyChanged(nameof(EnteredMoneyTotal)); } else { MessageBox.Show("Nicht genügend Geld eingeworfen. :(", "NEED MOAR MONEY!!!", MessageBoxButton.OK, MessageBoxImage.Warning); } }
/// <summary> /// Eject the entered money /// Show MessageBox with the money to be ejected /// </summary> private void EjectMoney() { StringBuilder message = new StringBuilder(); message.AppendLine($"Eingezahltes Geld wird zurückgegeben: {EnteredMoneyTotal:0.00}€"); message.AppendLine(); message.AppendLine(GetStringFromMoneyList(EnteredMoneyBits)); MessageBox.Show(message.ToString(), "Schade, dann halt nicht. :(", MessageBoxButton.OK, MessageBoxImage.Information); EnteredMoneyBits.Clear(); RaisePropertyChanged(nameof(EnteredMoneyTotal)); }