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