public ActionResult Edit(TermsOfPayment termsofpayment) { if (ModelState.IsValid) { db.Entry(termsofpayment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(termsofpayment); }
public ActionResult Create(TermsOfPayment termsofpayment) { ModelState.Remove("topNo"); if (ModelState.IsValid) { // generate new TermsOfPayment id var lastId = db.TermsOfPayments.Max(items => items.topNo); var newId = lastId + 1; termsofpayment.topNo = newId; db.TermsOfPayments.Add(termsofpayment); db.SaveChanges(); return RedirectToAction("Index"); } return View(termsofpayment); }