public ActionResult Create(Account account) { try { int custId = FindCustId(User.Identity.Name); _accountBl.CreateAccount(account.AccName.ToUpper(), account.AccountType, custId, 0); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { AccountBL accountBL = new AccountBL(); var persona = new Cliente { Nombre = model.Nombre, Direccion = model.Direccion, Email = model.Email, Password = model.Password, Rol = new List <Rol>() { new RolBL().GetRol((int)RolUser.User) } }; var result = accountBL.CreateAccount(persona); if (result.Succeeded) { SingIn(persona); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario return(View(model)); }
protected void CreateAccountButton_Click(object sender, EventArgs e) { if (IsValid) { byte isAdmin = 0; //customer byte status = 0; //per default not suspendet user var imgPath = " "; //as there is no profile img Random random = new Random(); confirmationID = random.Next(); lblRegResult.Text = " "; var check = bl.CreateAccount(TextEmail.Text.Trim(), TextPassword.Text.Trim(), TextFirstName.Text.Trim(), TextLastName.Text.Trim(), TextBirthday.Text.Trim(), TextPhone.Text.Trim(), imgPath, status, isAdmin, confirmationID); Debug.Write("Register Customer / Check Value : " + check); switch (check) { case 0: lblRegResult.Visible = true; lblRegResult.CssClass = "text-danger"; lblRegResult.Text = "Database error."; break; case 1: lblRegResult.Visible = true; lblRegResult.CssClass = "text-success"; lblRegResult.Text = "Password and email are correct."; MailSender(confirmationID); break; case 2: lblRegResult.Visible = true; lblRegResult.CssClass = "text-danger"; lblRegResult.Text = "The password format does not meet the requirements."; break; case 3: lblRegResult.Visible = true; lblRegResult.CssClass = "text-danger"; lblRegResult.Text = "The email format is wrong."; break; case 4: lblRegResult.Visible = true; lblRegResult.CssClass = "text-danger"; lblRegResult.Text = "The email is already taken."; break; default: lblRegResult.Visible = true; lblRegResult.CssClass = "text-danger"; lblRegResult.Text = "Error in account creation. Try later"; Debug.Write("Check : out of values"); break; } } }
public ActionResult SelectAPlan(string accountName, string friendlyName, string adminPassword, string adminPassword2, string adminEmail, string adminEmail2, int planType) { if (!AccountBL.AccountExists(accountName)) { AccountBL.CreateAccount(accountName, friendlyName, adminPassword, adminEmail, planType); ViewBag.Account = accountName; return(View("AccountCreated")); } else { ViewData.Model = planType; ViewBag.ErrorMessage = "Account '" + accountName + "' already exists. Please enter another name."; ViewBag.FriendlyName = friendlyName; ViewBag.AdminEmail = adminEmail; return(View("SelectPlan")); } }
static void OpenAccount(int customerId) { string menuString = "(1) Checking Account\n" + "(2) Business Account\n" + "(3) Loan Account\n" + "(4) Term Deposit Account\n"; Console.WriteLine(menuString); Console.Write("Enter the account type: "); Account newAccount = null; string accountType = Console.ReadLine(); switch (accountType) { case "1": newAccount = new Checking(); break; case "2": newAccount = new Business(); break; case "3": newAccount = new Loan(); break; case "4": newAccount = new TermDeposit(); break; default: Console.WriteLine("Invalid Input, returning to main menu...\n"); break; } if (newAccount != null) { newAccount.customerId = cid; AccountBL accountBL = new AccountBL(); accountBL.CreateAccount(newAccount); } }
public ActionResult Create(Account model) { if (ModelState.IsValid) { var account = accountBL.CreateAccount(model); if (account != null) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("Error", "Something went wrong. Please conatct support team."); return(View(model)); } } else { return(View(model)); } }
public static void menu() { Console.WriteLine("Welcome to the bank."); Console.WriteLine("What would you like to do?"); Console.WriteLine("1. Register as a new customer"); Console.WriteLine("2. Create a new account"); Console.WriteLine("3. Make a transaction on an exisitng account"); Console.WriteLine("4. View list of accounts for a customer"); string userChoice = Console.ReadLine(); switch (userChoice) { case "1": Console.WriteLine("Please enter your first name..."); string fname = Console.ReadLine(); Console.WriteLine("Please enter your last name..."); string lname = Console.ReadLine(); Console.WriteLine("Please enter your area code"); int areaCode = getAreaCode(); Console.WriteLine("Please enter you phone number..."); int phoneNumber = getPhoneNumber(); Customer customerNew = new Customer() { Id = Bank.custNumber, firstName = fname, lastName = lname, areaCode = areaCode, phoneNumber = phoneNumber }; Bank.custNumber++; CustomerBL customerBL = new CustomerBL(); Console.WriteLine(customerBL.Create(customerNew)); menu(); break; case "2": Console.WriteLine("Please enter your Customer ID"); int custId = getCustomerId(); Console.WriteLine("What type of account would you like to open?"); Console.WriteLine("Press 1 for Checking"); Console.WriteLine("Press 2 for Business"); Console.WriteLine("Press 3 for Term"); Console.WriteLine("Press 4 for Loan"); string type = Console.ReadLine(); double rate = 0.00; double balance = 0; if (type == "1") { type = "Checking"; rate = 0.11; IAccount accountNew = new Checking() { type = type, accountNumber = Bank.accntNumber, CustomerId = custId, InterestRate = rate, Balance = balance }; Bank.accntNumber++; AccountBL accountBL = new AccountBL(); Console.WriteLine(accountBL.CreateAccount(accountNew)); } else if (type == "2") { type = "Business"; rate = 1.14; IAccount accountNew = new Business() { type = type, accountNumber = Bank.accntNumber, CustomerId = custId, InterestRate = rate, Balance = balance }; Bank.accntNumber++; AccountBL accountBL = new AccountBL(); Console.WriteLine(accountBL.CreateAccount(accountNew)); } else if (type == "3") { type = "Term"; rate = 3.0; Console.WriteLine("How much would you like to deposit in your term account?"); balance = Convert.ToInt32(Console.ReadLine()); IAccount accountNew = new Term() { type = type, accountNumber = Bank.accntNumber, CustomerId = custId, InterestRate = rate, Balance = balance }; Bank.accntNumber++; AccountBL accountBL = new AccountBL(); Console.WriteLine(accountBL.CreateAccount(accountNew)); } else if (type == "4") { type = "Loan"; rate = 4.5; Console.WriteLine("How much would you like to take out as a loan?"); balance = 0 - Convert.ToInt32(Console.ReadLine()); IAccount accountNew = new Loan() { type = type, accountNumber = Bank.accntNumber, CustomerId = custId, InterestRate = rate, Balance = balance }; Bank.accntNumber++; AccountBL accountBL = new AccountBL(); Console.WriteLine(accountBL.CreateAccount(accountNew)); } else { invalidKey(); } Menu.menu(); break; case "3": Console.WriteLine("What is your account number?"); int accountId = getAccountNumber(); int accountIndex = Bank.AccountList.FindIndex(a => a.accountNumber.Equals(accountId)); Console.WriteLine("What is your Customer Id?"); int yourId = getCustomerId(); if (yourId != Bank.AccountList[accountIndex].CustomerId) { Console.WriteLine($"That is not the correct customer Id for account number {accountId}"); returnToMain(); } Console.WriteLine("What type of transaction would you like to make?"); Console.WriteLine("Press 1 for Withdrawl"); Console.WriteLine("Press 2 for Deposit"); Console.WriteLine("Press 3 to Transfer Funds between accounts"); Console.WriteLine("Press 4 to Check balance"); Console.WriteLine("Press 5 to View transaction log"); Console.WriteLine("Press 6 to Delete account"); string transType = Console.ReadLine(); if (transType == "1") { Console.WriteLine("How much would you like to withdraw?"); double amount = getAmount(); var accountType = Bank.AccountList[accountIndex].type; if (accountType == "Checking") { Checking accountNew = new Checking(); accountNew = (Checking)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.withdraw(amount)); returnToMain(); } else if (accountType == "Business") { Business accountNew = new Business(); accountNew = (Business)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.withdraw(amount)); returnToMain(); } else if (accountType == "Term") { Term accountNew = new Term(); accountNew = (Term)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.withdraw(amount)); returnToMain(); } else if (accountType == "Loan") { Loan accountNew = new Loan(); accountNew = (Loan)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.withdraw(amount)); returnToMain(); } } else if (transType == "2") { Console.WriteLine("How much would you like to deposit?"); var accountType = Bank.AccountList[accountIndex].type; double amount = getAmount(); if (accountType == "Checking") { Checking accountNew = new Checking(); accountNew = (Checking)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.deposit(amount)); returnToMain(); } else if (accountType == "Business") { Business accountNew = new Business(); accountNew = (Business)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.deposit(amount)); returnToMain(); } else if (accountType == "Term") { Term accountNew = new Term(); accountNew = (Term)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.deposit(amount)); returnToMain(); } else if (accountType == "Loan") { Loan accountNew = new Loan(); accountNew = (Loan)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.deposit(amount)); returnToMain(); } } else if (transType == "3") { Console.WriteLine("Enter the account number of the account you would like to transfer money to."); int toAccount = getAccountNumber(); if (!Menu.accountIdValidation(toAccount)) { Console.WriteLine("There is no account under that number."); Console.WriteLine("Please press enter to return to the main menu"); Console.ReadLine(); Menu.menu(); } int toAccountIndex = Bank.AccountList.FindIndex(a => a.accountNumber.Equals(toAccount)); if (yourId != Bank.AccountList[toAccountIndex].CustomerId) { Console.WriteLine($"That account is registered under a different customer."); Console.WriteLine("You can only transfer between your own accounts."); returnToMain(); } var toAccountType = Bank.AccountList[toAccount].type; var accountType = Bank.AccountList[accountIndex].type; Console.WriteLine("How much would you like to transfer?"); double amount = getAmount(); if (accountType == "Checking") { Checking accountNew = new Checking(); accountNew = (Checking)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.withdraw(amount)); if (toAccountType == "Checking") { Checking toAccountNew = new Checking(); toAccountNew = (Checking)Bank.AccountList[toAccountIndex]; Console.WriteLine(toAccountNew.deposit(amount)); Menu.menu(); } else if (toAccountType == "Business") { Business toAccountNew = new Business(); toAccountNew = (Business)Bank.AccountList[toAccountIndex]; Console.WriteLine(toAccountNew.deposit(amount)); Menu.menu(); } else { Console.WriteLine("You can only trasfer between Checking and Buisness accounts. "); Menu.menu(); } } else if (accountType == "Business") { Business accountNew = new Business(); accountNew = (Business)Bank.AccountList[accountIndex]; Console.WriteLine(accountNew.withdraw(amount)); if (toAccountType == "Checking") { Checking toAccountNew = new Checking(); toAccountNew = (Checking)Bank.AccountList[toAccountIndex]; Console.WriteLine(toAccountNew.deposit(amount)); Menu.menu(); } else if (toAccountType == "Business") { Business toAccountNew = new Business(); toAccountNew = (Business)Bank.AccountList[toAccountIndex]; Console.WriteLine(toAccountNew.deposit(amount)); Menu.menu(); } else { Console.WriteLine("You can only trasfer between Checking and Buisness accounts. "); Menu.menu(); } } else { Console.WriteLine("You can only trasfer between Checking and Buisness accounts. "); Menu.menu(); } } else if (transType == "4") { var yourBalance = Bank.AccountList[accountIndex].Balance; Console.WriteLine($"Your account balance is ${yourBalance}"); Menu.menu(); } else if (transType == "5") { var accountType = Bank.AccountList[accountIndex].type; if (accountType == "Checking") { Checking accountNew = new Checking(); accountNew = (Checking)Bank.AccountList[accountIndex]; foreach (Transaction item in accountNew.getLog()) { Console.WriteLine(item.message); } returnToMain(); } else if (accountType == "Business") { Business accountNew = new Business(); accountNew = (Business)Bank.AccountList[accountIndex]; foreach (Transaction item in accountNew.getLog()) { Console.WriteLine(item.message); } returnToMain(); } else if (accountType == "Term") { Term accountNew = new Term(); accountNew = (Term)Bank.AccountList[accountIndex]; foreach (Transaction item in accountNew.getLog()) { Console.WriteLine(item.message); } returnToMain(); } else if (accountType == "Loan") { Loan accountNew = new Loan(); accountNew = (Loan)Bank.AccountList[accountIndex]; foreach (Transaction item in accountNew.getLog()) { Console.WriteLine(item.message); } returnToMain(); } } else if (transType == "6") { Bank.AccountList.RemoveAt(accountIndex); Console.WriteLine($"You're account has been deleted"); Menu.menu(); } else { invalidKey(); } break; case "4": Console.WriteLine("Please enter your customer ID"); int CustId = getCustomerId(); if (!Menu.customerIdValidation(CustId)) { Console.WriteLine("There is no customer under that number."); returnToMain(); } else { Console.WriteLine("The customer Id you provided is associated with the following accounts..."); foreach (IAccount item in Bank.AccountList) { if (item.CustomerId == CustId) { Console.WriteLine($"{item.type} account with a balance of ${item.Balance} and an account number of {item.accountNumber}"); } } returnToMain(); } break; default: invalidKey(); break; } }