public HelperRequest DeleteDoctor(DeleteDoctorRequest 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 selectDoctorId = _context.Doctors.Where(doc => doc.LastName == request.LastName && doc.FirstName == request.FirstName).Select(x => x.IdDoctor).ToArray(); var doctor = new Doctor { IdDoctor = selectDoctorId[0] }; _context.Attach(doctor); _context.Remove(doctor); _context.SaveChangesAsync(); helper.Number = 1; return(helper); }
public void Delete(int id) { var request = new DeleteDoctorRequest(); request.Id = id; var response = HttpPost <DeleteDoctorRequest>("api/doctor/delete", request, MediaType.Json); }
public IActionResult DeleteDoctor(DeleteDoctorRequest deleteDoctorRequest) { var prescriptionList = _context.Prescription.Where(e => e.IdDoctor == deleteDoctorRequest.IdDoctor).ToList(); ArrayList prescription_MedicamantList = new ArrayList(); foreach (Prescription prescription in prescriptionList) { prescription_MedicamantList.Add(_context.GetPrescription_Medicamant.Where(e => e.IdPrescription == prescription.IdPrescription)); } foreach (GetPrescription_Medicamant prescription_Medicamant in prescription_MedicamantList) { _context.Remove(prescription_Medicamant); } foreach (Prescription prescription in prescriptionList) { _context.Remove(prescription); } _context.Remove(_context.Doctor.Where(e => e.IdDoctor == deleteDoctorRequest.IdDoctor).ToList().First()); _context.SaveChanges(); return(Ok("Usunieto doktora wraz ze wszystkimi receptami wystawionymi przez tego doktora")); }
public IActionResult DeleteDoctor(DeleteDoctorRequest request) { var prescriptions = _contex.Prescription.Where(e => e.IdDoctor == request.IdDoctor).ToList(); var prescriptionMedicamentList = new ArrayList(); foreach (Prescription prescription in prescriptions) { prescriptionMedicamentList.Add( _contex.PrescriptionMedicaments.Where(e => e.IdPrescription == prescription.IdPrescription)); } foreach (Prescription_Medicament prescriptionMedicament in prescriptionMedicamentList) { _contex.Remove(prescriptionMedicament); } foreach (Prescription prescription in prescriptions) { _contex.Remove(prescription); } _contex.Remove(_contex.Doctors.Where(e => e.IdDoctor == request.IdDoctor).ToList().First()); _contex.SaveChanges(); return(new OkObjectResult("Pomyślnie usunięto doktora wra ze wszystkimi wystawionymi przez niego receptami")); }
public DeleteDoctorResponse DeleteDoctor(DeleteDoctorRequest request) { var response = new DeleteDoctorResponse(); using (var doctorDbContext = new DoctorDbContext()) { var doctorToDelete = doctorDbContext.Doctors.SingleOrDefault(doctor => doctor.IdDoctor.Equals(request.IdDoctor)); if (doctorToDelete != null) { try { doctorDbContext.Doctors.Remove(doctorToDelete); doctorDbContext.SaveChanges(); response.message = "Doctor " + request.IdDoctor + " deleted successful"; } catch (Exception) { response.message = "Doctor delete FAILED"; } } else { response.message = "There is no such a doctor to delete!"; } } return(response); }
public IActionResult DaleteDoctor(DeleteDoctorRequest request) { request.IdDoctor = 1; var response = _serviceDoctor.DeleteDoctor(request); return(Ok(response.message)); }
public IActionResult DeleteDoctor(DeleteDoctorRequest request) { bool res = _context.DeleteDoctor(request); if (!res) { return(BadRequest("Brak podanego doktora")); } return(Ok()); }
public IActionResult deleteDoctor(DeleteDoctorRequest request) { Doctor doc = new Doctor(); doc.Id = request.Id; doc.FirstName = request.FirstName; doc.LastName = request.LastName; _DbService.DeleteDoctor(doc); return(Ok("Usunieto lekarza jakim jest: " + doc.FirstName + " " + doc.LastName)); }
public IActionResult DeleteDoctor(DeleteDoctorRequest request) { try { var doctor = _service.DeleteDoctor(request); return(Ok(doctor)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult RemoveDoctor(DeleteDoctorRequest request) { HelperRequest helperRequest = _context.DeleteDoctor(request); switch (helperRequest.Number) { case 0: return(BadRequest("Doctor with this Name and Lastname not exist")); default: return(Ok("Doctor remove")); } }
public bool DeleteDoctor(DeleteDoctorRequest request) { Doctor doc = _context.Doctors.Where(x => x.firstName == request.firstName) .Where(x => x.lastName == request.lastName).FirstOrDefault(); if (doc == null) { return(false); } _context.Doctors.Remove(doc); _context.SaveChanges(); return(true); }
public bool DeleteDoctor(DeleteDoctorRequest request) { _context = new DoctorsDbContext(); Doctor doctor; try { doctor = _context.Doctors.First(d => d.IdDoctor == Convert.ToInt32(request.IdDoctor)); } catch { return(false); } _context.Remove(doctor); _context.SaveChanges(); return(true); }
public void delete(DeleteDoctorRequest request) { try { var response = new DeleteDoctorResponse(); var bc = new DoctorComponent(); bc.Delete(request.Id); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public IActionResult DeleteDoctor(DeleteDoctorRequest request) { return(Ok(_service.DeleteDoctor(request))); }
public IActionResult DeleteDoctor(DeleteDoctorRequest request) { var response = _context.DeleteDoctor(request); return(response ? Ok("Usunięto doktora") : Ok(BadRequest("Błędne id doktora"))); }