public ActionResult Create(InvestmentAccount investmentaccount) { //This code has been modified if (ModelState.IsValid) { //Setting the investment account number to the next available one when creating a new investment account investmentaccount.SetNextAccountNumber(); db.BankAccounts.Add(investmentaccount); investmentaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", investmentaccount.AccountStateId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", investmentaccount.ClientId); return(View(investmentaccount)); }
public ActionResult Create(InvestmentAccount investmentaccount) { //calling the appropriate SetNext method investmentaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.BankAccounts.Add(investmentaccount); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccountStatusId = new SelectList(db.AccountStatus, "AccountStatusId", "Description", investmentaccount.AccountStatusId); //display fullnam instead of firstname //ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FirstName", investmentaccount.ClientId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", investmentaccount.ClientId); return(View(investmentaccount)); }
public ActionResult Create(InvestmentAccount investmentaccount) { investmentaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.BankAccounts.Add(investmentaccount); db.SaveChanges(); investmentaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", investmentaccount.AccountStateId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", investmentaccount.ClientId); return(View(investmentaccount)); }
public ActionResult Create(InvestmentAccount investmentaccount) { //Calling method for auto increment. investmentaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.BankAccounts.Add(investmentaccount); db.SaveChanges(); //Changes the accountstate if the account requirements are not fullfilled investmentaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } //Displays the fullname for the client ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", investmentaccount.ClientId); ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", investmentaccount.AccountStateId); return(View(investmentaccount)); }