예제 #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);
                        }
                    });
        }
예제 #2
0
        public LoanPaymentViewModel(IMessageBus messenger, Loan loan)
        {
            myLoan = loan;
            myMessenger = messenger;

            _MakePaymentCommand = new DelegateCommand(MakePaymentExecute, MakePaymentCanExecute);
        }
예제 #3
0
파일: Person.cs 프로젝트: Aesir/LoanTracker
        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;
        }