Exemple #1
0
        public void CreateAccount(int Number, int Balance, string Label, int Owner)
        {
            Account account = new Account(Number, Balance, Label, Owner);

            accounts.Add(account);
            JSONFileService.Save(accounts);
        }
Exemple #2
0
        public void MoveBalance(int outgoingAccountNumber, int incomingAccountNumber, int amount)
        {
            int outgoingIndex = GetAccountIndexByNumber(outgoingAccountNumber);
            int incomingIndex = GetAccountIndexByNumber(incomingAccountNumber);

            if (amount < 0)
            {
                Console.WriteLine("Invalid amount.");
                return;
            }
            if (amount > accounts[outgoingIndex].Balance)
            {
                Console.WriteLine("Balance too low.");
                return;
            }

            accounts[outgoingIndex].Balance -= amount;
            accounts[incomingIndex].Balance += amount;

            JSONFileService.Save(accounts);
        }
Exemple #3
0
 public AccountsService()
 {
     accounts = JSONFileService.GetAccounts();
 }