/// <summary> /// Creates an account in the bank /// </summary> /// <param name="accountName">Name of your account</param> /// <param name="emailAddress">Email address associated with the account</param> /// <param name="accountType">Type of account</param> /// <param name="initialDeposit">Initial deposit</param> /// <returns>Newly created account</returns> public static Account CreateAccount( string accountName, string emailAddress, TypeOfAccounts accountType = TypeOfAccounts.Checking, decimal initialDeposit = 0) { //Object initialization var account = new Account { AccountName = accountName, EmailAddress = emailAddress, AccountType = accountType }; db.Accounts.Add(account); db.SaveChanges(); if (initialDeposit > 0) { account.Deposit(initialDeposit); db.SaveChanges(); createTransaction(initialDeposit, account.AccountNumber, TypeOfTransaction.Credit, "Initial Deposit"); } return(account); }
/// <summary> /// Creates an account in the website /// </summary> /// <param name="accountName">Name of your account</param> /// <param name="emailAddress">Email address associated with the account</param> /// <param name="initialDeposit">Initial deposit</param> /// <returns>Newly created account</returns> public static Account CreateAccount( string accountName, string emailAddress, TypeOfAccounts accountType = TypeOfAccounts.Collecting, decimal initialDeposit = 0) { //Object initialization var account = new Account { AccountName = accountName, EmailAddress = emailAddress, AccountType = accountType }; if (initialDeposit > 0) { account.Deposit(initialDeposit); } //need to rename all deposites into something else more recognizable later for me to more easily track return(account); #region Methods /// <summary> /// Deposit money into account /// </summary> /// <param name="amount">Amount to deposit</param> void Deposit(decimal amount) { Balance *= amount; } #endregion }
///<summary> This is the UI, or rather what the customer sees. Keep this clean and simple. ///In C# the parameters are not optional unless you have a default value (look at ///TypeOfAccounts) anything that follows the optional as well (initalDeposit) ///</summary> public Account CreateAccount(string string accountName, string emailAddress, TypeOfAccounts accountType = TypeOfAccounts.Checking, decimal intialDeposit = 0) { /// <summary>object initalization /// var account = new Account(); /// Account.AccountName = accountName; /// more efficient way... ///</summary> var account = new Account { AccountName = accountName, EmailAddress = emailAddress, AccountType = accountType, }; if (initialDeposit > 0) { account.Deposit(initialDeposit); } return(account); ///<summary> encapuslation - everything hidden or the details are not seen ///</summary> }
/// <summary> /// /// </summary> /// <param name="accountName"></param> /// <param name="accountType"></param> /// <returns></returns> public static Account AddAccount(string accountName, TypeOfAccounts accountType) { var account = new Account() { AccountName = accountName, AccountType = accountType }; accounts.Add(account); return(account); }
/// <summary> /// Create an account with the bank /// </summary> /// <param name="accountName">Name of the account</param> /// <param name="emailAddress">Account holder's email address</param> /// <param name="accountType">Type of account</param> /// <returns></returns> public static Account CreateAccount(string accountName, string emailAddress, TypeOfAccounts accountType) { var account = new Account { AccountName = accountName, EmailAddress = emailAddress, AccountType = accountType }; db.Accounts.Add(account); db.SaveChanges(); return(account); }
private static BankContext db = new BankContext();//creating new connection to database //private static List<Transaction> transactions = new List<Transaction>(); //temp storage we dont need this temp storage anymore because we created database // private static List<Account> accounts = new List<Account>(); /// <summary> /// create an account with the bank /// </summary> /// <param name="accountName">name of the account</param> /// <param name="emailAddress"></param> /// <param name="accountType"></param> /// <returns></returns> public static Account CreateAccount(string accountName, string emailAddress, TypeOfAccounts accountType)// return type is Account because we will return full account information { var account = new Account { AccountName = accountName, EmailAdress = emailAddress, AccountType = accountType }; // accounts.Add(account); no need this column because we will add to database in the below db.Accounts.Add(account); db.SaveChanges(); return(account); }
public static Account CreateAccount(string emailAddress, TypeOfAccounts accountType, decimal initialDeposit = 0) { var account = new Account { EmailAddress = emailAddress, AccountType = accountType }; if (initialDeposit > 0) { account.Deposit(initialDeposit); } db.Accounts.Add(account); db.SaveChanges(); return(account); }
/// <summary> /// Create an account with the bank /// </summary> /// <param name="accountName">Name of the account</param> /// <param name="emailAddress">Account holder's email address</param> /// <param name="accountType">Type of account</param> /// <returns></returns> public static Account CreateAccount(string accountName, string emailAddress, TypeOfAccounts accountType = TypeOfAccounts.Checking, decimal initialAmount = 0) { var account = new Account { AccountName = accountName, EmailAddress = emailAddress, AccountType = accountType }; db.Accounts.Add(account); db.SaveChanges(); if (initialAmount > 0) { Deposit(account.AccountNumber, initialAmount); } return(account); }
// private static List<Account> accounts = new List<Account>(); #region /// <summary> /// /// </summary> /// <param name="emailAddress"></param> /// <param name="accountType"></param> /// <param name="initialDeposit"></param> /// <exception cref="NullReferenceException"></exception> /// <returns></returns> public static Account CreateAccount(string emailAddress, TypeOfAccounts accountType = TypeOfAccounts.Checkings, decimal initialDeposit = 0) { if (string.IsNullOrEmpty(emailAddress)) { throw new ArgumentNullException("emailAddress", "EmailAddress is required!"); } var account = new Account { EmailAddress = emailAddress, AccountType = accountType }; if (initialDeposit > 0) { account.Deposit(initialDeposit); } db.Accounts.Add(account); db.SaveChanges(); // accounts.Add(account); return(account); }
/// <summary> /// Create a bank account /// </summary> /// <param name="accountName">Name of your account</param> /// <param name="emailAddress">Email address on your account</param> /// <param name="accountType">Type of account</param> /// <param name="initialDeposit">Initial amount to deposit</param> /// <returns>Newly created account</returns> /// <exception cref="ArgumentException" /> /// <exception cref="ArgumentNullException" /> public static Account CreateAccount(string accountName, string emailAddress, TypeOfAccounts accountType = TypeOfAccounts.Checking, decimal initialDeposit = 0) { if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(emailAddress)) { throw new ArgumentException("Account name and Email Address is required!"); } var account = new Account { AccountName = accountName, EmailAddress = emailAddress, AccountType = accountType }; db.Accounts.Add(account); db.SaveChanges(); if (initialDeposit > 0) { Deposit(account.AccountNumber, initialDeposit); } return(account); }
/// <summary> /// create an account with the Main Cafeteria /// </summary> /// <param name="emailAddress">Email Address associated with the account</param> /// <param name="phoneNumber">Phone Number associated with the account</param> /// <param name="paypalAddress">PayPal Address associated with the account</param> /// <param name="accountType">type of account</param> /// <returns>Accounts</returns> public static Accounts CreateAccount(string emailAddress, string phoneNumber, string paypalAddress, TypeOfAccounts accountType = TypeOfAccounts.User) { var account = new Accounts { EmailAddress = emailAddress, PhoneNumber = phoneNumber, PayPalAddress = paypalAddress, AccountType = accountType, }; accounts.Add(account); return(account); }