public ActionResult Create(Lease lease) { if (ModelState.IsValid) { _db.Leases.Add(lease); _db.SaveChanges(); return RedirectToAction("Index"); } return View(lease); }
public ActionResult Edit(Lease lease) { var oldLease = _db.Leases.Find(lease.LeaseId); lease.Equipment = oldLease.Equipment; lease.Comments = oldLease.Comments; lease.PurchaseCooperativeId = oldLease.PurchaseCooperativeId; lease.LocationId = oldLease.LocationId; lease.Location = oldLease.Location; lease.Operator = oldLease.Operator; lease.OperatorId = oldLease.OperatorId; if (ModelState.IsValid) { _db.Entry(lease).State = EntityState.Modified; _db.SaveChanges(); return RedirectToAction("Index"); } var allErrors = ModelState.Values.SelectMany(v => v.Errors); return View(lease); }