コード例 #1
0
 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();
 }
コード例 #2
0
 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();
         }
     }
 }
コード例 #3
0
 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();
         }
     }
 }
コード例 #4
0
 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();
 }