Esempio n. 1
0
        public void LockBankAccount(BankAccountsDTO bankAccounts)
        {
            if (bankAccounts == null)
            {
                throw new ArgumentNullException(nameof(bankAccounts));
            }

            // keresés azonosító alapján
            BankAccountsDTO bankAccountsToLock = _bankAccounts.FirstOrDefault(b => b.ID == bankAccounts.ID);

            if (bankAccountsToLock == null)
            {
                throw new ArgumentException("The building does not exist.", nameof(bankAccounts));
            }

            bankAccountsToLock.isLocked = !bankAccountsToLock.isLocked;

            // külön kezeljük, ha egy adat újonnan hozzávett (ekkor nem kell törölni a szerverről)
            if (_bankAccountsFlags.ContainsKey(bankAccountsToLock) && _bankAccountsFlags[bankAccountsToLock] == DataFlag.Create)
            {
                _bankAccountsFlags[bankAccountsToLock] = DataFlag.Create;
            }
            else
            {
                _bankAccountsFlags[bankAccountsToLock] = DataFlag.Update;
            }

            OnAccountChanged(bankAccounts.ID);
        }
Esempio n. 2
0
        public void TakeOut(TransactionDTO transaction)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            transaction.ID = (_transactions.Count > 0 ? _transactions.Max(b => b.ID) : 0) + 1;
            _transactionsFlags.Add(transaction, DataFlag.Create);
            _transactions.Add(transaction);
            BankAccountsDTO bankacc = _bankAccounts.FirstOrDefault(f => f.ID == transaction.AccountID);

            bankacc.Balance = bankacc.Balance - transaction.TransactionValue;
            if (_bankAccountsFlags.ContainsKey(bankacc) && _bankAccountsFlags[bankacc] == DataFlag.Create)
            {
                _bankAccountsFlags[bankacc] = DataFlag.Create;
            }
            else
            {
                _bankAccountsFlags[bankacc] = DataFlag.Update;
            }


            OnAccountChanged(bankacc.ID);
        }
Esempio n. 3
0
        public void Tran(TransactionDTO transaction)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            transaction.ID = (_transactions.Count > 0 ? _transactions.Max(b => b.ID) : 0) + 1;
            _transactionsFlags.Add(transaction, DataFlag.Create);
            _transactions.Add(transaction);
            BankAccountsDTO bankacc = _bankAccounts.FirstOrDefault(f => f.ID == transaction.AccountID);

            bankacc.Balance = bankacc.Balance - transaction.TransactionValue;
            if (_bankAccountsFlags.ContainsKey(bankacc) && _bankAccountsFlags[bankacc] == DataFlag.Create)
            {
                _bankAccountsFlags[bankacc] = DataFlag.Create;
            }
            else
            {
                _bankAccountsFlags[bankacc] = DataFlag.Update;
            }


            OnAccountChanged(bankacc.ID);


            BankAccountsDTO recbankacc = _bankAccounts.FirstOrDefault(f => f.AccountNumber == transaction.AccountNumberTo && f.ClientName == transaction.ReceiverName);

            if (recbankacc != null)
            {
                TransactionDTO rectran = new TransactionDTO
                {
                    TransactionValue  = transaction.TransactionValue,
                    TransactionType   = "Jóváírás",
                    Created           = DateTime.Now,
                    AccountNumberFrom = bankacc.AccountNumber
                };
                _transactionsFlags.Add(rectran, DataFlag.Create);
                _transactions.Add(rectran);

                recbankacc.Balance = recbankacc.Balance + transaction.TransactionValue;
                if (_bankAccountsFlags.ContainsKey(recbankacc) && _bankAccountsFlags[recbankacc] == DataFlag.Create)
                {
                    _bankAccountsFlags[recbankacc] = DataFlag.Create;
                }
                else
                {
                    _bankAccountsFlags[recbankacc] = DataFlag.Update;
                }

                OnAccountChanged(recbankacc.ID);
            }
        }
Esempio n. 4
0
        private void LockBankAccount(BankAccountsDTO bankAccount)
        {
            if (bankAccount == null || !BankAccounts.Contains(bankAccount))
            {
                return;
            }
            var result = MessageBox.Show("Biztos benne?", "Figyelmeztetés", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes;

            if (result)
            {
                _model.LockBankAccount(bankAccount);
            }
        }
Esempio n. 5
0
        public async Task <Boolean> UpdateAccountAsync(BankAccountsDTO bankAccounts)
        {
            try
            {
                HttpResponseMessage response = await _client.PutAsJsonAsync("api/bankaccounts/", bankAccounts);

                return(response.IsSuccessStatusCode);
            }
            catch (Exception ex)
            {
                throw new PersistenceUnavailableException(ex);
            }
        }
Esempio n. 6
0
        private void UpdateBuilding(BankAccountsDTO bankAccount)
        {
            if (bankAccount == null)
            {
                return;
            }

            EditedBankAccount = new BankAccountsDTO
            {
                ID            = bankAccount.ID,
                ClientName    = bankAccount.ClientName,
                AccountNumber = bankAccount.AccountNumber,
                Balance       = bankAccount.Balance,
                Created       = bankAccount.Created,
                isLocked      = bankAccount.isLocked
            };
        }
Esempio n. 7
0
        public IActionResult PutBankAccounts([FromBody] BankAccountsDTO bankAccountsDTO)
        {
            try
            {
                BankAccounts bankAccounts = _context.BankAccounts.FirstOrDefault(b => b.ID == bankAccountsDTO.ID);

                if (bankAccounts == null) // ha nincs ilyen azonosító, akkor hibajelzést küldünk
                {
                    return(NotFound());
                }

                bankAccounts.Balance  = bankAccountsDTO.Balance;
                bankAccounts.isLocked = bankAccountsDTO.isLocked;

                _context.SaveChanges(); // elmentjük a módosított épületet

                return(Ok());
            }
            catch
            {
                // Internal Server Error
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }