private void PayDrink(string PayMethod, double insertedMoney = 0) { RemainingPriceToPay = _paymentFactory.Pay(PayMethod).remainingPriceToPay(this._selectedDrink, this._selectedPaymentCardUsername, this._remainingPriceToPay, LogText, insertedMoney); if (RemainingPriceToPay == 0) { _selectedDrink.LogDrinkMaking(LogText); LogText.Add("------------------"); _selectedDrink = null; } this.RaisePropertyChanged(() => this.PaymentCardRemainingAmount); }
static void Main(string[] args) { IUnityContainer container = new UnityContainer(); BusinessRuleRegistrar.Register(container); var paymentFactory = new PaymentFactory(container); var payment = new Payment { Agent = new BusinessRuleEngine.Entities.Agents.Agent { Name = "Intikhab" }, Customer = new BusinessRuleEngine.Entities.Customers.Customer { Name = "Joe", Email = "*****@*****.**", Membership = new BusinessRuleEngine.Entities.Memberships.Membership { IsActive = false, MembershipType = BusinessRuleEngine.Entities.Memberships.MembershipType.Normal } }, Department = new BusinessRuleEngine.Entities.Departments.Department { DepartmentType = BusinessRuleEngine.Entities.Departments.DepartmentType.Royality, Name = "Royality Dept." }, PaymentType = PaymentType.Book, PaymentValue = 10, VideoType = BusinessRuleEngine.Entities.Videos.VideoType.LearningToSki }; var response = paymentFactory.Pay(payment); if (response.PaymentResponseType == PaymentResponseType.Success) { Console.WriteLine($"Payment is successful for the payment type = '{payment.PaymentType.ToString()}'."); } else { Console.WriteLine("Payment Failed. Reasoin is given below."); Console.WriteLine(response.ErrorMessage); } Console.ReadLine(); }
public MainViewModel() { _teaBlendRepository = new TeaBlendRepository(); Blends = new ObservableCollection <string>(_teaBlendRepository.BlendNames); _drinkFactory = new DrinkFactory(); _paymentFactory = new PaymentFactory(); _coffeeStrength = Strength.Normal; _sugarAmount = Amount.Normal; _milkAmount = Amount.Normal; LogText = new ObservableCollection <string>(); LogText.Add("Starting up..."); LogText.Add("Done, what would you like to drink?"); PaymentCardUsernames = new ObservableCollection <string>(_paymentFactory.Pay("CARD").GetCashOnCards().Keys); SelectedPaymentCardUsername = PaymentCardUsernames[0]; }