public ActionResult Approve(int id = 0) { var lease = _db.Leases.Find(id); if (lease == null) { return(HttpNotFound()); } var viewModel = new ApproveLeaseViewModel { LeaseName = lease.Name, Id = lease.LeaseId, OpName = lease.Operator.Name }; return(View(viewModel)); }
public ActionResult Approve(ApproveLeaseViewModel viewModel) { var lease = _db.Leases.Find(viewModel.Id); if (lease == null) { return(HttpNotFound()); } if (ModelState.IsValid) { lease.Pending = false; lease.Comments.Add(viewModel.Comment); _db.Entry(lease).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(viewModel)); }