Exemplo n.º 1
0
 public static Person PersonByName(string name)
 {
     using (var db = new BankingSystemEntities())
     {
         return(db.People.FirstOrDefault(p => p.Name == name));
     }
 }
Exemplo n.º 2
0
 public static SavingsAccount SavingsAccount(int personId)
 {
     using (var db = new BankingSystemEntities())
     {
         return(db.SavingsAccounts.FirstOrDefault(p => p.PersonId == personId));
     }
 }
Exemplo n.º 3
0
 public static Person PersonById(int id)
 {
     using (var db = new BankingSystemEntities())
     {
         return(db.People.FirstOrDefault(p => p.ID == id));
     }
 }
Exemplo n.º 4
0
 public static bool CheckingsExistsForPerson(int personId)
 {
     using (var db = new BankingSystemEntities())
     {
         return(db.CheckingsAccounts.FirstOrDefault(s => s.PersonId == personId) != null);
     }
 }
Exemplo n.º 5
0
 public static bool PersonExists(string name)
 {
     using (var db = new BankingSystemEntities())
     {
         return(db.People.FirstOrDefault(p => p.Name == name) != null);
     }
 }
Exemplo n.º 6
0
 public static void Person(int id, string name)
 {
     using (var db = new BankingSystemEntities())
     {
         var person = db.People.FirstOrDefault(p => p.ID == id);
         if (person == null)
         {
             return;
         }
         person.Name = name;
         db.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public static void SavingsAccountAmount(Guid id, decimal amount)
 {
     using (var db = new BankingSystemEntities())
     {
         var account = db.SavingsAccounts.FirstOrDefault(a => a.AccountId == id);
         if (account == null)
         {
             return;
         }
         account.Amount = amount;
         db.SaveChanges();
     }
 }
Exemplo n.º 8
0
        public static int Person(string name)
        {
            using (var db = new BankingSystemEntities())
            {
                var person = new Person
                {
                    Name = name
                };

                db.People.Add(person);
                db.SaveChanges();
                return(person.ID);
            }
        }
Exemplo n.º 9
0
 public static Guid CheckingsAccount(int personId, decimal amount)
 {
     using (var db = new BankingSystemEntities())
     {
         var account = new CheckingsAccount
         {
             PersonId  = personId,
             AccountId = Guid.NewGuid(),
             Amount    = amount
         };
         db.CheckingsAccounts.Add(account);
         db.SaveChanges();
         return(account.AccountId);
     }
 }