Esempio n. 1
0
 public Money SubFunds(Money fundsToSub)
 {
     var exchange = ExchangePoint.Instance;
     Money normalizedMoney = exchange.CurrentValueFor(fundsToSub, this.Currency);
     double newAmount = this.Amount - normalizedMoney.Amount;
     return new Money(this.Currency, newAmount);
 }
Esempio n. 2
0
 public static bool EditCurrencyInAccount(Account account, Currency newCurrency)
 {
     BankContext bank = new BankContext();
     var accountInDb = bank.Accounts.SingleOrDefault(a => a.Id == account.Id);
     if (accountInDb != null)
     {
         Money money = new Money(accountInDb.Currency,accountInDb.Amount);
         money.Exchange(newCurrency);
         accountInDb.Currency = newCurrency;
         accountInDb.Amount = money.Amount;
         bank.SaveChanges();
         return true;
     }
     return false;
 }
Esempio n. 3
0
 public Money CurrentValueFor(Money money, Currency currency)
 {
     double exchange = ExchangeRate(money.Currency, currency);
     return new Money(currency, (double)money.Amount * exchange);
 }