public ActionResult Edit(ChequingAccount chequingaccount) { chequingaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.Entry(chequingaccount).State = EntityState.Modified; db.SaveChanges(); chequingaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId); return(View(chequingaccount)); }
public ActionResult Create(ChequingAccount chequingaccount) { //this code has been modified if (ModelState.IsValid) { //Setting the chequing account number to the next available one when creating a new chequing account chequingaccount.SetNextAccountNumber(); db.BankAccounts.Add(chequingaccount); chequingaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId); return(View(chequingaccount)); }
public ActionResult Create(ChequingAccount chequingaccount) { //calling the appropriate SetNext method chequingaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.BankAccounts.Add(chequingaccount); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AccountStatusId = new SelectList(db.AccountStatus, "AccountStatusId", "Description", chequingaccount.AccountStatusId); //display fullnam instead of firstname //ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FirstName", chequingaccount.ClientId); ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId); return(View(chequingaccount)); }
public ActionResult Create(ChequingAccount chequingaccount) { //Added this line of code to set the next account number chequingaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.BankAccounts.Add(chequingaccount); db.SaveChanges(); chequingaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } //Modified the following parameters to include FullName and NOT FirstName ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId); ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId); return(View(chequingaccount)); }
public ActionResult Create(ChequingAccount chequingaccount) { //Calling method for auto increment. chequingaccount.SetNextAccountNumber(); if (ModelState.IsValid) { db.BankAccounts.Add(chequingaccount); db.SaveChanges(); //code for database chequingaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId); ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId); return(View(chequingaccount)); }