Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 public virtual void Update(T entity)
 {
     dbset.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
 }