private void UpdateInfoAfterNewDrink() { RemainingPriceToPay = _drinkFactory.SelectedDrink.GetPrice(); LogText.Add($"Selected {_drinkFactory.SelectedDrink.GetName()}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}"); RaisePropertyChanged(() => SelectedDrinkName); RaisePropertyChanged(() => SelectedDrinkPrice); }
private void SendUpdate() { //ensure that it does not need to look at the sugar price and such. RemainingPriceToPay = _selectedDrink.Price; RaisePropertyChanged(() => RemainingPriceToPay); RaisePropertyChanged(() => SelectedDrinkName); RaisePropertyChanged(() => SelectedDrinkPrice); LogText.Add($"Selected {_selectedDrink.Name}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}"); }
public void Pay(double inserted) { if (User.Balance >= RemainingPriceToPay) { User.Balance -= inserted; RemainingPriceToPay = 0; LogText.Add($"Inserted {inserted.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); } else { double moneyLeft = User.Balance; User.Balance = 0; RemainingPriceToPay -= moneyLeft; LogText.Add($"Inserted {moneyLeft.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); } Notify(this); }
private void SendDrinkUpdate() { RemainingPriceToPay = _selectedDrink.Price; LogText.Add($"Selected {_selectedDrink.Name}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}"); }
private void PayDrink(bool payWithCard, double insertedMoney = 0) { if (_selectedDrink != null && payWithCard) { insertedMoney = _cashOnCards[SelectedPaymentCardUsername]; if (RemainingPriceToPay <= insertedMoney) { _cashOnCards[SelectedPaymentCardUsername] = insertedMoney - RemainingPriceToPay; RemainingPriceToPay = 0; } else // Pay what you can, fill up with coins later. { _cashOnCards[SelectedPaymentCardUsername] = 0; RemainingPriceToPay -= insertedMoney; } LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); RaisePropertyChanged(() => PaymentCardRemainingAmount); } else if (_selectedDrink != null && !payWithCard) { RemainingPriceToPay = Math.Max(Math.Round(RemainingPriceToPay - insertedMoney, 2), 0); LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); } if (_selectedDrink != null && RemainingPriceToPay == 0) { _selectedDrink.LogDrinkMaking(LogText); LogText.Add("------------------"); _selectedDrink = null; } }
// return true if fully paid public bool payByCoin(ObservableCollection <string> log, double insertedMoney) { RemainingPriceToPay = Math.Max(Math.Round(RemainingPriceToPay - insertedMoney, 2), 0); log.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}"); return(RemainingPriceToPay == 0); }
// return true if fully paid public bool payByCard(ObservableCollection <string> log) { double insertedMoney = _cashOnCards[SelectedPaymentCardUsername]; if (RemainingPriceToPay <= insertedMoney) { _cashOnCards[SelectedPaymentCardUsername] = insertedMoney - RemainingPriceToPay; RemainingPriceToPay = 0; } else // Pay what you can, fill up with coins later { _cashOnCards[SelectedPaymentCardUsername] = 0; RemainingPriceToPay -= insertedMoney; } log.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}"); return(RemainingPriceToPay == 0); }
private void PayDrink(bool payWithCard, double insertedMoney = 0) { if (_selectedDrink != null && payWithCard) { card.Username = SelectedPaymentCardUsername; insertedMoney = card.CashOncards[SelectedPaymentCardUsername]; RemainingPriceToPay = card.PayDrink(RemainingPriceToPay); RaisePropertyChanged(() => PaymentCardRemainingAmount); } else if (_selectedDrink != null && !payWithCard) { RemainingPriceToPay = paymentFactory.CreatePayment("Coin", insertedMoney, null).PayDrink(RemainingPriceToPay); } LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); if (_selectedDrink != null && RemainingPriceToPay == 0) { _selectedDrink.LogDrinkMaking(LogText); LogText.Add("------------------"); _selectedDrink = null; } }
private void HandlePayment(object sender, PaymentSystem.PriceChanged e) { RemainingPriceToPay = e.RemainingPrice; _userRepository = e.UserRepository; _cashOnCards = _userRepository.Cards; RaisePropertyChanged(() => PaymentCardRemainingAmount); LogText.Add($"Inserted {e.InsertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); if (_selectedDrink != null && RemainingPriceToPay <= 0) { MakeDrink(); } }
private void PrintSelectionAndPrice() { bool hasSugar = false; bool hasMilk = false; if (SugarAmount != Amount.None && _selectedDrink.CompatibleToppings.Contains("Sugar")) { hasSugar = true; } if (MilkAmount != Amount.None && !_selectedDrink.CompatibleToppings.Contains("Milk")) { hasMilk = true; } RemainingPriceToPay = _selectedDrink.GetPrice(); LogText.Add($"Selected {_selectedDrink.Name}{(hasSugar ? hasMilk ? " with sugar and milk" : " with sugar" : hasMilk ? " with Milk" : "")}, price: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}"); RaisePropertyChanged(() => RemainingPriceToPay); RaisePropertyChanged(() => SelectedDrinkName); RaisePropertyChanged(() => SelectedDrinkPrice); }
public void Pay(double inserted) { RemainingPriceToPay = Math.Max(Math.Round(RemainingPriceToPay - inserted, 2), 0); LogText.Add($"Inserted {inserted.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); Notify(this); }
public void PayDrinkByCoins(double insertedMoney) { _payFactory.getPayMethod("Coin").Pay(insertedMoney, RemainingPriceToPay); RemainingPriceToPay = _payFactory.getPayMethod("Coin").getRemainingPriceToPay(); LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); if (_selectedDrink != null && RemainingPriceToPay == 0) { _selectedDrink.LogDrinkMaking(LogText); LogText.Add("------------------"); _selectedDrink = null; } }
public void PayDrinkByCard() { if (_selectedDrink != null) { double insertedMoney = _cashOnCards[SelectedPaymentCardUsername]; _payFactory.getPayMethod("Card").Pay(_cashOnCards[SelectedPaymentCardUsername], RemainingPriceToPay); _cashOnCards[SelectedPaymentCardUsername] = _payFactory.getPayMethod("Card").getNewAmount(); RemainingPriceToPay = _payFactory.getPayMethod("Card").getRemainingPriceToPay(); LogText.Add($"Inserted {insertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); RaisePropertyChanged(() => PaymentCardRemainingAmount); } if (_selectedDrink != null && RemainingPriceToPay == 0) { _selectedDrink.LogDrinkMaking(LogText); LogText.Add("------------------"); _selectedDrink = null; } }