public ActionResult Edit(Company company) { if (ModelState.IsValid) { var entry = db.Entry(company); entry.State = EntityState.Modified; // Tell EF do not modify the property 'CreatedDate' entry.Property("CreatedDate").IsModified = false; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(company)); }
public ActionResult Edit(SalesMan salesman) { if (ModelState.IsValid) { var entry = db.Entry(salesman); entry.State = EntityState.Modified; entry.Property(a => a.CreatedDate).IsModified = false; entry.Property(a => a.CompanyId).IsModified = false; entry.Property(a => a.IsLicenced).IsModified = false; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(salesman)); }
public ActionResult Edit([Bind(Include = "Id,Name,Gender,PlateNumber,VIN,Phone,Address,Source,Comment,CityId")] Client client) { var user = Session["user"] as User; client.CompanyId = user.CompanyId.Value; if (ModelState.IsValid) { var entry = db.Entry(client); entry.State = EntityState.Modified; //更新时排除Code entry.Property("Code").IsModified = false; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Cities = new SelectList(db.Cities.ToList(), "Id", "Name", client.CityId); return(View(client)); }