public void UpdateDoctor(int id, Doctor doc) { var doctor = new Doctor { IdDoctor = id, FirstName = doc.FirstName, LastName = doc.LastName, Email = doc.Email }; _context.Attach(doctor); if (doc.FirstName != null) { _context.Entry(doctor).Property("FirstName").IsModified = true; } if (doc.LastName != null) { _context.Entry(doctor).Property("LastName").IsModified = true; } if (doc.Email != null) { _context.Entry(doctor).Property("Email").IsModified = true; } _context.SaveChanges(); }
public void UpdateDoctor(AddOrUpdateDoctorRequest req, int id) { var doctor = _context.Doctor.Find(id); if (doctor == null) { return; } _context.Entry(doctor).CurrentValues.SetValues(req); _context.SaveChanges(); }
public virtual void Update(T entity) { dbset.Attach(entity); dataContext.Entry(entity).State = EntityState.Modified; }