Beispiel #1
0
        /// <summary>
        /// Creates a New Account and Add the Account to the BankDatabase
        /// </summary>
        /// <returns>The Account Number for the New Account</returns>
        public static long CreateAccount()
        {
            string customerLastName;
            string customerFirstName;
            string customerPhoneNumber;
            string customerEmailAddress;
            string customerHomeAddress;

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            UserInterface.DisplayMessageLine("\n\t\t\t\t      ***Account Creation***\n");
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Cyan;
            UserInterface.DisplayMessageLine("\n\t\t\t\t---------Customer Details-------");
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Blue ;
            UserInterface.DisplayMessageLine("\n\t\t\t\t         Enter Last Name       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerLastName = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t        Enter First Name       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerFirstName = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t       Enter Phone Number       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerPhoneNumber = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t      Enter Email Address       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerEmailAddress = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t      Enter Home Address       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();
            customerHomeAddress = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\t\tEnter Account Type, 0 For Savings Account , 1 For Current Account       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();
            int accountType = int.Parse(UserInterface.GetInput());

            long customerNewAccountNumber = GenerateAccountNumber();//Generates A new Account Number For The Customer

            string fullCustomerName = customerLastName +"  " + customerLastName;

            BankDatabase bankdatabase = BankDatabase.GetInstance();

            Account newAccount = null;

               switch(accountType){
               case (int)AccountType.Savings:
                   newAccount = new SavingsAccount(customerNewAccountNumber, Convert.ToDecimal(0.00), fullCustomerName, DateTime.Now);
                   break;
              case (int)AccountType.Current:
                   newAccount = new CurrentAccount(customerNewAccountNumber, Convert.ToDecimal(0.00), fullCustomerName, DateTime.Now);
                   break;

               }

               bankdatabase.AddNewAccount(newAccount);

            Customer newCustomer = new Customer(customerNewAccountNumber, customerLastName, customerFirstName,customerPhoneNumber, customerEmailAddress, customerEmailAddress);
            bankdatabase.AddNewCustomer(newCustomer);

            return customerNewAccountNumber;
        }
 /// <summary>
 /// Adds a New Customer to Database on Account Creation
 /// </summary>
 /// <param name="customer">A Customer Object</param>
 public void AddNewCustomer(Customer customer)
 {
     customers.Add(customer.CustomerAccountNumber,customer);
 }