public ActionResult Edit([Bind(Include = "Id,DoctorId,Name,Special,LicenseExpirationDate")] DoctorViewModel dvm) { if (ModelState.IsValid) { try { IBL bl = new BLImplement(); var doctor = new Doctor() { DoctorId = dvm.DoctorId, Name = dvm.Name, LicenseExpirationDate = Convert.ToDateTime(dvm.LicenseExpirationDate), Special = bl.getAllSpecialties().Where(s => s.SpecialtyName == dvm.SpecialName).FirstOrDefault().Id }; bl.updateDoctor(doctor); ViewBag.Message = String.Format("The doctor {0} is successfully updated", doctor.Name); } catch (Exception ex) { ViewBag.Message = String.Format(ex.Message); return(RedirectToAction("Index")); } //db.Entry(doctorViewModel).State = EntityState.Modified; return(RedirectToAction("Index")); } return(View(dvm)); }