public HelperRequest UpdateDoctor(UpdateDoctorRequest request) { var helper = new HelperRequest(); var countDoctor = _context.Doctors.Count(doc => doc.LastName == request.LastName && doc.FirstName == request.FirstName); if (countDoctor == 0) { helper.Number = 0; return(helper); } var doctor = new Doctor { FirstName = request.FirstName, LastName = request.LastName, Email = request.Email, }; _context.Attach(doctor); _context.Entry(doctor).Property("FirstName").IsModified = true; _context.Entry(doctor).Property("LastName").IsModified = true; _context.Entry(doctor).Property("Email").IsModified = true; _context.SaveChangesAsync(); helper.Number = 1; return(helper); }
public Doctor AddDoctor(Doctor doctor) { db.Attach(doctor); db.Entry(doctor).State = EntityState.Added; db.SaveChanges(); return(doctor); }
public async Task <IHttpActionResult> PutPatient(int id, Patient patient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != patient.Id) { return(BadRequest()); } db.Entry(patient).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PatientExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <Doctor> UpdateDoctor(Doctor newDoctor) { var currentDoctor = await GetDoctor(newDoctor.IdDoctor); if (currentDoctor == null) { return(null); } if (newDoctor.FirstName != null) { currentDoctor.FirstName = newDoctor.FirstName; } if (newDoctor.LastName != null) { currentDoctor.LastName = newDoctor.LastName; } if (newDoctor.Email != null) { currentDoctor.Email = newDoctor.Email; } _dbContext.Entry(currentDoctor).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); return(newDoctor); }
public Appointment CancelAppointment(Appointment appointment) { appointment.Status = CancelStatus; //Default value 0 for Cancel db.Entry(appointment).State = EntityState.Modified; db.SaveChanges(); return(appointment); }
public IActionResult UpdateDoctor(Doctor doctor) { _context.Entry(doctor).State = EntityState.Modified; _context.SaveChanges(); return(Ok("Zaktualizowano doktora " + doctor)); }