public ActionResult Edit(MortgageAccount mortgageaccount) { if (ModelState.IsValid) { db.Entry(mortgageaccount).State = EntityState.Modified; db.SaveChanges(); mortgageaccount.ChangeState(); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientId = new SelectList(db.Clients, "ClientId", "FullName", mortgageaccount.ClientId); ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", mortgageaccount.AccountStateId); return(View(mortgageaccount)); }
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) { //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)); }