public void PerformDatabaseUpdate(int id, int money) { using (var db = new AccountDbContext()) { var entity = db.SetAccount.Find(id); if (entity != null) { entity.Amount = entity.Amount + money; db.SaveChanges(); } } Console.WriteLine(); Console.WriteLine("Amount Deposited"); Console.WriteLine(); }
public void PerformDatabasePrinting() { using (var db = new AccountDbContext()) { var list = db.SetAccount.ToList(); if (list != null) { foreach (var accountInfo in list) { Console.Write("Account Number :- {0} \nFull Name :- {1} \nAmount :- {2} \nAccount Type :- {3}", accountInfo.Account_Number, accountInfo.Full_Name, accountInfo.Amount, accountInfo.Account_Type); Console.WriteLine(); Console.WriteLine("-------------------------------------------------------------------------------------"); Console.WriteLine(); } Console.WriteLine(); } } }
public void PerformeDatabasePrint(int id) { using (var db = new AccountDbContext()) { var accountDetail = db.SetAccount.Find(id); if (accountDetail != null) { string output = "Account Number :- "; output += accountDetail.Account_Number; output += "\n Full Name is :- "; output += accountDetail.Full_Name; output += "\n Amount is :- "; output += accountDetail.Amount; output += "\n Account Type is :- "; output += accountDetail.Account_Type; Console.WriteLine(output); Console.WriteLine(); } } }
public void PerformDatabaseInterest(int id) { using (var db = new AccountDbContext()) { var entity = db.SetAccount.Find(id); if (entity != null) { if (entity.Account_Type == "savings") { int interest = (entity.Amount * 4) / 100; Console.WriteLine("Interest is :- " + interest); } else { int interest = (entity.Amount * 1) / 100; Console.WriteLine("Interest is :- " + interest); } } } Console.WriteLine(); }