Beispiel #1
0
        public LoanViewModel(IMessageBus messenger, Loan loan)
        {
            myLoan = loan;
            _OweTo = myLoan.Lender.Name;
            _APR = myLoan.APR;
            _OutstandingBalance = myLoan.OutstandingBalance(DateTime.Now);

            _MakePaymentCommand = new DelegateCommand(MakePaymentExecute, MakePaymentCanExecute);

            myMessenger = messenger;
            myMessenger
                .Listen<Loan>("PaymentMade")
                .ObserveOnDispatcher()
                .Subscribe(
                    l =>
                    {
                        if (l == myLoan)
                        {
                            myMessenger.SendMessage<Person>(loan.Lender, "BalanceChanged");
                            myMessenger.SendMessage<Person>(loan.Borrower, "BalanceChanged");
                            this.PaymentMaker = null;
                            this.OutstandingBalance = myLoan.OutstandingBalance(DateTime.Now);
                        }
                    });
        }
        public LoanPaymentViewModel(IMessageBus messenger, Loan loan)
        {
            myLoan = loan;
            myMessenger = messenger;

            _MakePaymentCommand = new DelegateCommand(MakePaymentExecute, MakePaymentCanExecute);
        }
Beispiel #3
0
        public bool Borrow(Person lender, decimal amount)
        {
            Contract.Requires(lender != null);
            Contract.Requires(amount > 0);

            if (!lender.Withdraw(amount))
            {
                return false;
            }
            else
            {
                this.Deposit(amount);
            }

            var loan = new Loan(lender, this, amount, 6.0m);
            this._Borrowed.Add(loan);
            lender._Lent.Add(loan);
            return true;
        }