Example #1
0
 /// <summary>
 /// RemoveAccount возвращает true, если account был удален, false в противном случае
 /// </summary>
 /// <param name="account"></param>
 /// <returns></returns>
 public static bool RemoveAccount(Account account)
 {
     BankContext bank = new BankContext();
     if(bank.Accounts.Find(account.Id) != null)
     {
         bank.Accounts.Remove(account);
         bank.SaveChanges();
         return true;
     }
     return false;
 }
Example #2
0
        public static void CreateAccount(User client, Currency currency)
        {
            BankContext bank = new BankContext();
            Account account = new Account();

            account.ClientId = client.Id;
            account.OpeningDate = DateTime.UtcNow;
            account.Currency = currency;
            account.Amount = 0;

            bank.Accounts.Add(account);
            bank.SaveChanges();
        }
Example #3
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;
 }
Example #4
0
 public static void AddCredit(Account account, Currency currency, double amount, double rate, PaymentType payment, int term)
 {
     BankContext bank = new BankContext();
     bank.Credits.Add(new Credit()
     {
         AccountId = account.Id,
         Currency = currency,
         Amount = amount,
         Rate = rate,
         PaymentType = payment,
         Months = term,
         LoanDate = DateTime.UtcNow,
         Status = CreditStatus.Active
     });
     bank.SaveChanges();
 }