public async Task <IActionResult> PutPatient(int id, Patient patient) { if (id != patient.Id) { return(BadRequest()); } _context.Entry(patient).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PatientExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRequestCancellation(int id, RequestCancellation requestCancellation) { if (id != requestCancellation.Id) { return(BadRequest()); } _context.Entry(requestCancellation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestCancellationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DoctorActivateDeactivateSession(int doctorId, int state) { if (_context.DoctorActivate.Where(p => p.Activate == true & p.DoctorId == doctorId & p.EndTime == null).Count() >= 1 && state == 1) { var result = new { meta = "Ok", message = "Doctor is already activate" }; return(Ok(result)); } if (_context.Doctor.Find(doctorId) != null) { if (state == 1) { try { var doctorActivate = new DoctorActivate { Activate = true, DoctorId = doctorId }; _context.DoctorActivate.Add(doctorActivate); _context.SaveChanges(); } catch (Exception e) { return(BadRequest()); } var result = new { status = "OK", message = "Doctor Activate Session" }; return(Ok(result)); } else { if (_context.DoctorActivate.Where(p => p.DoctorId == doctorId && p.Activate == true).Count() >= 1) { var doctorDeactivate = _context.DoctorActivate.Where(p => p.DoctorId == doctorId && p.Activate == true).Single(); doctorDeactivate.Activate = false; doctorDeactivate.EndTime = DateTime.Now; _context.Entry(doctorDeactivate).State = EntityState.Modified; _context.SaveChanges(); var result = new { status = "OK", message = "Deactivate session successfully" }; return(Ok(result)); } return(BadRequest()); } } else { var result = new { status = "Bad", message = "Incorrect doctorID" }; return(BadRequest(result)); } }