Beispiel #1
0
        //<summary>
        //added code
        //<summary>
        public static async Task <bool> AddMoney(BankAccount account, decimal money, BankAccount opossiteAccount, string reason = "")
        {
            Interfaces.IDataService _dataService = DataService.GetDataService();
            if (money < 0)
            {
                return(false);
            }

            Transaction transaction = new Transaction {
                Account = account, Amount = money, Reason = reason
            };

            transaction.TransactionLog += account.Log;
            account.TransactionQueue.Add(transaction);
            bool result = await transaction.Queue();

            account.TransactionQueue.Remove(transaction);

            account.PreviousTransactions.Add(transaction);

            //<summary>
            //added code
            //<summary>

            Transaction oppossitetransaction = new Transaction {
                Account = opossiteAccount, Amount = -money, Reason = reason
            };

            transaction.TransactionLog += opossiteAccount.Log;
            opossiteAccount.TransactionQueue.Add(oppossitetransaction);
            result = await oppossitetransaction.Queue();

            opossiteAccount.TransactionQueue.Remove(oppossitetransaction);
            opossiteAccount.PreviousTransactions.Add(oppossitetransaction);

            _dataService.AddTransaction(transaction);
            _dataService.UpdateBank(opossiteAccount);
            _dataService.UpdateBank(account);
            var UserSuperAccount         = _dataService.ReturnAllUsers().Where(a => a.Accounts.Where(a => a.Id == account.Id).Any()).FirstOrDefault();
            var OppositeUserSuperAccount = _dataService.ReturnAllUsers().Where(a => a.Accounts.Where(a => a.Id == opossiteAccount.Id).Any()).FirstOrDefault();

            _dataService.UpdateUser(UserSuperAccount);
            _dataService.UpdateUser(OppositeUserSuperAccount);

            //<summary>
            //added code
            //<summary>

            return(result);
        }
Beispiel #2
0
        public static async Task <bool> AddMoney(BankAccount account, decimal money, string reason = "")
        {
            Interfaces.IDataService _dataService = DataService.GetDataService();
            if (money < 0)
            {
                return(false);
            }

            Transaction transaction = new Transaction {
                Account = account, Amount = money, Reason = reason, dummytransaction = false, Id = Guid.NewGuid().ToString(), LastExecuted = DateTime.Now
            };

            transaction.TransactionLog += account.Log;
            account.TransactionQueue.Add(transaction);
            bool result = await transaction.Queue();

            account.TransactionQueue.Remove(transaction);

            account.PreviousTransactions.Add(transaction);

            //<summary>
            //added code start
            //<summary>
            _dataService.AddTransaction(transaction);
            _dataService.UpdateBank(account);
            var UserSuperAccount = _dataService.ReturnAllUsers().Where(a => a.Accounts.Where(a => a.Id == account.Id).Any()).FirstOrDefault();

            _dataService.UpdateUser(UserSuperAccount);
            //<summary>
            //added code end
            //<summary>

            return(result);
        }