コード例 #1
0
 public void PerformDatabaseOperations(int accountId, string name, string type)
 {
     using (var db = new AccountDbContext())
     {
         if (type == "savings")
         {
             var person = new Account
             {
                 Account_Number = accountId,
                 Full_Name      = name,
                 Amount         = 1000,
                 Account_Type   = type
             };
             db.SetAccount.Add(person);
             db.SaveChanges();
         }
         else
         {
             var person = new Account
             {
                 Account_Number = accountId,
                 Full_Name      = name,
                 Amount         = 0,
                 Account_Type   = type
             };
             db.SetAccount.Add(person);
             db.SaveChanges();
         }
     }
     Console.WriteLine();
 }
コード例 #2
0
        public void PerformDatabaseWithdrawl(int id, int money)
        {
            using (var db = new AccountDbContext())
            {
                var entity = db.SetAccount.Find(id);
                if (entity != null)
                {
                    if (entity.Account_Type == "savings" && entity.Amount > (1000 + money))
                    {
                        entity.Amount = entity.Amount - money;

                        Console.WriteLine("Amount Withdrawl");
                    }
                    else if (entity.Account_Type == "current" && entity.Amount > money)
                    {
                        entity.Amount = entity.Amount - money;

                        Console.WriteLine("Amount Withdrawl");
                    }
                    else
                    {
                        Console.WriteLine("Amount can not be less than 0 for current account type or 1000 for savings account type");
                    }
                    db.SaveChanges();
                }
            }
            Console.WriteLine();
            Console.WriteLine();
        }
コード例 #3
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();
 }