Exemplo n.º 1
0
 public ActionResult Edit(Account account)
 {
     if (!ModelState.IsValid)
         return View(account);
     BankFactory.UpdateAccount(account);
     return RedirectToAction("MyAccount");
 }
Exemplo n.º 2
0
 public static Account CreateAccount(string name, int ssn)
 {
     var account = new Account(name);
     account.SSN = ssn;
     accounts.Add(account);
     return account;
 }
Exemplo n.º 3
0
 public static void CreateAccount(Account account)
 {
     using (var db = new BankModel())
     {
         db.Accounts.Add(account);
         db.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public static Account CreateAccount(string name,int ssn,decimal amount)
        {
            var account = new Account(name,amount);
            account.SSN = ssn;

            //account.Name = name;
            //account.Deposit(amount);
            return account;
        }
Exemplo n.º 5
0
 public static Account CreateAccount(string name, int SSN, decimal amount)
 {
     //var account = CreateAccount(name);
     var account = new Account(name, amount);
     account.SSN = SSN;
     //account.Name = name;
     //account.Deposit(amount);
     return account;
 }
Exemplo n.º 6
0
 static void Main(string[] args)
 {
     // left hand sife is definition and right side is instantiation (memory allocated)
     Account myAccount = new Account();
     /// this is not going to work because the Balance property in the Account is private set
     // myAccount.Balance = 100000000;
     // but the get would work because the read is not private
     Console.WriteLine(myAccount.Balance);
     Console.ReadKey();
 }
Exemplo n.º 7
0
 public static void UpdateAccount(Account account)
 {
     using (var db = new BankModel())
     {
         var foundAccount = db.Accounts.Where(a => a.AccountNumber == account.AccountNumber).First();
         account.Balance = foundAccount.Balance;
         db.Entry(foundAccount).CurrentValues.SetValues(account);
         db.SaveChanges();
     }
 }
Exemplo n.º 8
0
 //method is called CreateAccount, which creates an account;
 //returns account, takes in 2 parameters;
 //creates accounts for us
 public static Account CreateAccount(string name, int ssn, decimal amount)
 {
     //var account = CreateAccount(name);
     var account = new Account(name,amount);
     //account.Name = name;
     //account.Deposit(amount);
     account.SSN = ssn;
     //account.TypeOfAccount = AccountType.Checking;
     return account;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a bank account
 /// </summary>
 /// <param name="name">Name of the account holder</param>
 /// <param name="ssn">ssn</param>
 /// <param name="balance">initial balance to be deposited</param>
 /// <returns>Account number</returns>
 public static Account CreateAccount(string name, int ssn, double balance)
 {
     Account account = new Account(name);
     account.SSN = ssn;
     account.AccountType = TypeOfAccount.Checking;
     if (balance > 0)
     {
         account.Deposit(balance);
     }
     return account;
 }
Exemplo n.º 10
0
 public static Account CreateAccount(string name, int ssn, decimal amount, AccountType accountType)
 {
     //var account = new Account();
     //account.Name = name;
     //account.Deposit(amount);
     var account = new Account(name, amount);
     account.SSN = ssn;
     account.TypeOfAccount = accountType;
     accounts.Add(account);
     return account;
 }
Exemplo n.º 11
0
 //private static List<Account> accounts = new List<Account>();
 public static Account CreateAccount(string name, int ssn)
 {
     using (var db = new BankModel())
     {
         var account = new Account(name);
         account.SSN = ssn;
         //accounts.Add(account);
         db.Accounts.Add(account);
         db.SaveChanges();
         return account;
     }
 }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            //Below two lines are commented because they call the default constructor and I want to isolate to the statement calling the overloaded constructor that accepts the name as a parameter
            //Account CheckingAccountVariable1 = new Account();
            //CheckingAccountVariable1.AccountHolderName = "Casie";
            Account CheckingAccountVariable1 = new Account("Casie");
            Console.WriteLine("Account Number: {0}, Name: {1}, Balance: {2}",
                CheckingAccountVariable1.AccountNumber, CheckingAccountVariable1.AccountHolderName, CheckingAccountVariable1.Balance);
            //CheckingAccount.AccountNumber = 10; //this is an example of what won't work because the set is a private set

            Account CheckingAccountVariable2 = new Account();
            CheckingAccountVariable2.AccountHolderName = "Brandon";
            Console.WriteLine("Account Number: {0}, Name: {1}, Balance: {2}",
                CheckingAccountVariable2.AccountNumber, CheckingAccountVariable2.AccountHolderName, CheckingAccountVariable2.Balance);
        }
Exemplo n.º 13
0
 public static Account CreateAccount(string name, int ssn, decimal amount, AccountType accountType, string emailAddress)
 {
     //var account = CreateAccount(name);
     //account.Deposit(amount);
     using (var db = new BankModel())
     {
         var account = new Account(name, amount);
         account.SSN = ssn;
         account.TypeOfAccount = accountType;
         account.EmailAddress = emailAddress;
         //accounts.Add(account);
         db.Accounts.Add(account);
         db.SaveChanges();
         return account;
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a bank account
 /// </summary>
 /// <param name="name">Name of the account holder</param>
 /// <param name="ssn">ssn</param>
 /// <param name="balance">initial balance to be deposited</param>
 /// <returns>Account number</returns>
 public static Account CreateAccount(string name, int ssn, double balance)
 {
     using (var db = new BankModel())
     {
         Account account = new Account(name);
         account.SSN = ssn;
         account.AccountType = TypeOfAccount.Checking;
         if (balance > 0)
         {
             account.Deposit(balance);
         }
         accounts.Add(account);
         db.Accounts.Add(account);
         db.SaveChanges();
         return account;
     }
 }
Exemplo n.º 15
0
 public static Account CreateAccount(string name, int SSN)
 {
     var account = new Account(name);
     account.SSN = SSN;
     return account;
 }