/// <summary>
        /// 1. etsitään oikea tili, jolle tilitapahtuma kirjataan
        /// 2. tilin saldo (Balance) laitetaan vastaaman oikeaa suoritusta +/- tapahtuma
        /// 3. päivitetään Account:n Balance
        /// 4. Tallennetaan muutokset sekä Transaction että Account tauluihin
        /// </summary>
        /// <param name="transaction"></param>
        /// <returns></returns>
        //public bool AddTransaction(Transaction transaction)
        //{
        //    bool res = false;
        //    using (var context = new BankdbContext())
        //    {
        //        try
        //        {
        //            context.Add(transaction);
        //            var account = GetAccountByIban(transaction.Iban);
        //            decimal balanceBeforeTransaction = account.Balance;
        //            var lastTransaction = GetTransactionsOfAccount(transaction.Iban);
        //            int result = DateTime.Compare(transaction.TimeStamp, lastTransaction.TimeStamp);
        //            if (result>0)
        //            {
        //                account.Balance += transaction.Amount;
        //            }
        //            if (account.Balance - transaction.Amount == balanceBeforeTransaction)
        //            {
        //                res = true;
        //            }

        //            //Update Account-table
        //            context.Account.Update(account);

        //            context.SaveChanges();
        //        }
        //        catch (Exception ex)
        //        {
        //            throw new NotImplementedException($"{ex.Message}\n{ex.InnerException.Message} \n");
        //        }
        //        return res;
        //    }
        //}
        /// <summary>
        /// 1. etsitään oikea tili, jolle tilitapahtuma kirjataan
        /// 2. tilin saldo (Balance) laitetaan vastaaman oikeaa suoritusta +/- tapahtuma
        /// 3. päivitetään Account:n Balance
        /// 4. Tallennetaan muutokset sekä Transaction että Account tauluihin
        /// </summary>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public void AddTransaction(Transaction transaction)
        {
            using (var context = new BankdbContext())
            {
                try
                {
                    //Lisätään tapahtumatauluun rivi
                    context.Add(transaction);

                    //Etsitään tili, jonka tietoja päivitetään
                    var account = GetAccountByIban(transaction.Iban);
                    //Lasketaan tilille uusi saldoa
                    account.Balance += transaction.Amount;

                    //Update Account-table
                    context.Account.Update(account);
                    //Tallennetaan muutokset tietokantaan
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new NotImplementedException($"{ex.Message}\n{ex.InnerException.Message} \n");
                }
            }
        }
示例#2
0
        public void Create(Bank bank)
        {
            string sql = $"INSERT INTO BANK (ID, NAME, BIC" +
                         $"VALUES ({bank.Id}, {bank.Name}, {bank.BIC})";

            _BankdbContext.Add(bank);
            _BankdbContext.SaveChanges();
        }
示例#3
0
        public void Create(Customer customer)
        {
            string sql = $"INSERT INTO CUSTOMER (ID, FIRSTNAME, LASTNAME, BANKID" +
                         $"VALUES ({customer.Id}, {customer.Firstname}, {customer.Lastname}, {customer.BankId})";

            _BankdbContext.Add(customer);
            _BankdbContext.SaveChanges();
        }
        public void Create(Account account)
        {
            string sql = $"INSERT INTO ACCOUNT (IBAN, NAME, BANKID, CUSTOMERID, BALANCE" +
                         $"VALUES ({account.IBAN}, {account.Name}, {account.BankId}, {account.CustomerId}, {account.Balance})";

            _BankdbContext.Add(account);
            _BankdbContext.SaveChanges();
        }
        public void Create(Transaction transaction)
        {
            string sql = $"INSERT INTO TRANSACTION (ID, IBAN, AMOUNT, TIMESTAMP" +
                         $"VALUES ({transaction.Id}, {transaction.IBAN}, {transaction.Amount}, {transaction.TimeStamp})";

            _BankdbContext.Add(transaction);
            _BankdbContext.SaveChanges();
        }
        public void AddAccount(Account account)
        {
            using (var context = new BankdbContext())
                try
                {
                    context.Add(account);

                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new NotImplementedException($"{ex.Message}\n{ex.InnerException.Message}");
                }
        }
示例#7
0
 public void Create(Bank bank)
 {
     using (var context = new BankdbContext())
     {
         try
         {
             context.Add(bank);
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new NotImplementedException($"{ex.Message}\n{ex.InnerException.Message} \nXXX");
         }
     }
 }
示例#8
0
        public void CreateCustomer(Customer customer) //Lisää
        {
            using (var context = new BankdbContext())
            {
                try
                {
                    context.Add(customer);

                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new NotImplementedException($"{ex.Message}\n{ex.InnerException.Message}");
                }
            }
        }
示例#9
0
 public void AddBank(Bank bank)
 {
     using (var context = new BankdbContext())
     {
         try
         {
             //Lisätään tapahtumatauluun rivi
             context.Add(bank);
             //Tallennetaan muutokset tietokantaan
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new NotImplementedException($"{ex.Message}\n{ex.InnerException.Message}");
         }
     }
 }
        public void AddTransaction(Transaction transaction)
        {
            using (var context = new BankdbContext())
            {
                try
                {
                    context.Add(transaction);
                    var     account = GetAccountByIban(transaction.Iban);
                    decimal balanceBeforeTransaction = account.Balance;
                    account.Balance += transaction.Amount;

                    //Update account-table
                    context.Account.Update(account);
                    //Tallennetaan muutokset tietokantaan
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
示例#11
0
        public void CreateTransaction(Transaction transaction)
        {
            using (var context = new BankdbContext())
            {
                try
                {
                    context.Add(transaction);


                    var account = GetAccountByIban(transaction.Iban);

                    account.Balance += transaction.Amount;

                    context.Account.Update(account);

                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new NotImplementedException($"{ex.Message}\n{ex.InnerException.Message}");
                }
            }
        }
示例#12
0
 public void AddTransaction(Transaction transaction)
 {
     using (var context = new BankdbContext())
     {
         try
         {
             //Lisätään tapahtumiin rivi
             context.Add(transaction);
             //Etsitään oikea tili
             var     account = GetAccountByIban(transaction.Iban);
             decimal balanceBeforeTransaction = account.Balance;
             //Lasketaan uusi saldo
             account.Balance += transaction.Amount;
             //Update account table
             context.Account.Update(account);
             //Tallennetaan muutokset
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
 public void CreateTransaction(Transaction transaction)
 {
     _bankdbContext.Add(transaction);
     _bankdbContext.SaveChanges();
 }
示例#14
0
 public void Create(Bank bank)
 {
     _bankdbContext.Add(bank);
     _bankdbContext.SaveChanges();
     Console.WriteLine($"Bank created. Bank name: {bank.Name} BIC: {bank.BIC}");
 }
示例#15
0
 public void Create(Account account)
 {
     _bankdbContext.Add(account);
     _bankdbContext.SaveChanges();
     Console.WriteLine($"Account created with name: {account.Name} and IBAN: {account.IBAN}");
 }
示例#16
0
 public void CreateCustomer(Customer customer)
 {
     _bankdbContext.Add(customer);
     _bankdbContext.SaveChanges();
 }
示例#17
0
 public Transaction Create(Transaction transaction)
 {
     _bankdbContext.Add(transaction);
     _bankdbContext.SaveChanges();
     return(transaction);
 }
 public void CreateAccount(Account account)
 {
     _context.Add(account);
     _context.SaveChanges();
 }
示例#19
0
 public void Create(Bank bank)
 {
     _bankdbContext.Add(bank);
     _bankdbContext.SaveChanges();
 }
 public Customer Create(Customer customer)
 {
     _bankdbContext.Add(customer);
     _bankdbContext.SaveChanges();
     return(customer);
 }
示例#21
0
 public void Create(Account account)
 {
     _bankdbContext.Add(account);
     _bankdbContext.SaveChanges();
 }
示例#22
0
        //Create

        public Account Create(Account account)
        {
            _context.Add(account);
            _context.SaveChanges();
            return(account);
        }
示例#23
0
 public void Create(Customer customer)
 {
     _bankdbContext.Add(customer);
     _bankdbContext.SaveChanges();
     Console.WriteLine($"Customer created. Full name: {customer.FirstName} {customer.LastName}");
 }
示例#24
0
 public void Create(Transaction transaction)
 {
     _bankdbContext.Add(transaction);
     _bankdbContext.SaveChanges();
     Console.WriteLine($"Added transaction with id: {transaction.Id} amount: {transaction.Amount} to {transaction.IBAN}");
 }
示例#25
0
 public Bank Create(Bank bank)
 {
     _bankdbContext.Add(bank);
     _bankdbContext.SaveChanges();
     return(bank);
 }