/// <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"); } } }
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(); }
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}"); } }
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"); } } }
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}"); } } }
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); } } }
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}"); } } }
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(); }
public void Create(Bank bank) { _bankdbContext.Add(bank); _bankdbContext.SaveChanges(); Console.WriteLine($"Bank created. Bank name: {bank.Name} BIC: {bank.BIC}"); }
public void Create(Account account) { _bankdbContext.Add(account); _bankdbContext.SaveChanges(); Console.WriteLine($"Account created with name: {account.Name} and IBAN: {account.IBAN}"); }
public void CreateCustomer(Customer customer) { _bankdbContext.Add(customer); _bankdbContext.SaveChanges(); }
public Transaction Create(Transaction transaction) { _bankdbContext.Add(transaction); _bankdbContext.SaveChanges(); return(transaction); }
public void CreateAccount(Account account) { _context.Add(account); _context.SaveChanges(); }
public void Create(Bank bank) { _bankdbContext.Add(bank); _bankdbContext.SaveChanges(); }
public Customer Create(Customer customer) { _bankdbContext.Add(customer); _bankdbContext.SaveChanges(); return(customer); }
public void Create(Account account) { _bankdbContext.Add(account); _bankdbContext.SaveChanges(); }
//Create public Account Create(Account account) { _context.Add(account); _context.SaveChanges(); return(account); }
public void Create(Customer customer) { _bankdbContext.Add(customer); _bankdbContext.SaveChanges(); Console.WriteLine($"Customer created. Full name: {customer.FirstName} {customer.LastName}"); }
public void Create(Transaction transaction) { _bankdbContext.Add(transaction); _bankdbContext.SaveChanges(); Console.WriteLine($"Added transaction with id: {transaction.Id} amount: {transaction.Amount} to {transaction.IBAN}"); }
public Bank Create(Bank bank) { _bankdbContext.Add(bank); _bankdbContext.SaveChanges(); return(bank); }