public List<Doctor> GetAllDoctors() { List<DoctorBDO> doctorsList; try { doctorsList = doctorLogic.GetAllDoctors(); } catch (Exception e) { var msg = e.Message; var reason = "GetAllDoctors exception"; throw new FaultException<DoctorFault> (new DoctorFault(msg), reason); } if (doctorsList == null) { var msg = "ListOfDoctors is empty"; var reason = "ListOfDoctors empty"; throw new FaultException<DoctorFault> (new DoctorFault(msg), reason); } List<Doctor> doctors = new List<Doctor>(); foreach (DoctorBDO doc in doctorsList) { var doctor = new Doctor(); TranslateDoctorBDOToDoctorDTO(doc, doctor); doctors.Add(doctor); } return doctors; }
public Patient GetAppointmentsHistoryPatient(int id, ref string message) { Patient patient = GetPatient(id); PatientBDO patientBDO = new PatientBDO(); try { TranslatePatientDTOToPatientBDO(patient, patientBDO); bool succesfull = new AppointmentLogic().GetAppointmentsHistoryPatient(ref patientBDO, ref message); if (succesfull == true) { TranslatePatientBDOToPatientDTO(patientBDO, patient); patient.appointmentsHistory = new List<Appointment>(); foreach (var appointment in patientBDO.appointmentsHistory) { Doctor doctorDTO = new Doctor(); new DoctorService().TranslateDoctorBDOToDoctorDTO(appointment.doctor, doctorDTO); patient.appointmentsHistory.Add(new Appointment { id = appointment.id, serviceType = appointment.serviceType, doctor = doctorDTO, time = appointment.time }); if (appointment.visit != null) { patient.appointmentsHistory.Last().visit = new Visit { id = appointment.visit.id, advice = appointment.visit.advice, patientProblem = appointment.visit.patientProblem, symptom = appointment.visit.symptom }; } } return patient; } else return null; } catch (Exception e) { var msg = e.Message; throw new FaultException<PatientFault>(new PatientFault(msg), msg); } }
public bool DeleteDoctor(ref Doctor doctor, ref string message) { var result = false; try { var doctorBDO = new DoctorBDO(); TranslateDoctorDTOToDoctorBDO(doctor, doctorBDO); result = doctorLogic.DeleteDoctor( ref doctorBDO, ref message); } catch (Exception e) { var msg = e.Message; throw new FaultException<DoctorFault> (new DoctorFault(msg), msg); } return result; }
private void TranslateAppointmentBDOToAppointmentDTO( AppointmentBDO AppointmentBDO, Appointment Appointment) { Doctor doctorDTO = new Doctor(); new DoctorService().TranslateDoctorBDOToDoctorDTO(AppointmentBDO.doctor, doctorDTO); Patient patientDTO = new Patient(); new PatientService().TranslatePatientBDOToPatientDTO(AppointmentBDO.patient, patientDTO); Appointment.id = AppointmentBDO.id; Appointment.patient = patientDTO; Appointment.serviceType = AppointmentBDO.serviceType; Appointment.time = AppointmentBDO.time; Appointment.doctor = doctorDTO; Appointment.RowVersion = AppointmentBDO.rowVersion; }
public List<List<String>> GetAllDoctorsSafe() { List<DoctorBDO> doctorsList; try { doctorsList = doctorLogic.GetAllDoctors(); } catch (Exception e) { var msg = e.Message; var reason = "GetAllDoctors exception"; throw new FaultException<DoctorFault> (new DoctorFault(msg), reason); } if (doctorsList == null) { var msg = "ListOfDoctors is empty"; var reason = "ListOfDoctors empty"; throw new FaultException<DoctorFault> (new DoctorFault(msg), reason); } List<List<String>> doctors = new List<List<String>>(); foreach (DoctorBDO doc in doctorsList) { var doctor = new Doctor(); TranslateDoctorBDOToDoctorDTO(doc, doctor); List<String> auxDoctorInfo = new List<String>(); auxDoctorInfo.Add(doc.lastName + doc.firstName); auxDoctorInfo.Add(doc.specialty); auxDoctorInfo.Add(doc.city); auxDoctorInfo.Add(doc.phoneNr); doctors.Add(auxDoctorInfo); } return doctors; }
private bool DoctorCheck(ref Doctor doctor, ref string message) { var result = true; if (string.IsNullOrEmpty(doctor.firstName)) { message = "Doctor's first name cannot be empty"; result = false; } else if (string.IsNullOrEmpty(doctor.lastName)) { message = "Doctor's last name cannot be empty"; result = false; } else if (string.IsNullOrEmpty(doctor.city)) { message = "Doctor's city cannot be empty"; result = false; } else if (doctor.zip <= 0) { message = "Doctor's zip cannot be empty or smaller or equal to 0"; result = false; } else if (string.IsNullOrEmpty(doctor.street)) { message = "Doctor's street cannot be empty"; result = false; } else if (doctor.streetNr <= 0) { message = "Doctor's street number cannot be empty or smaller or equal to 0"; result = false; } else if (string.IsNullOrEmpty(doctor.phoneNr)) { message = "Doctor's phone number cannot be empty"; result = false; } else if (string.IsNullOrEmpty(doctor.login)) { message = "Doctor's username cannot be empty"; result = false; } else if (string.IsNullOrEmpty(doctor.pass)) { message = "Doctor's password cannot be empty"; result = false; } else if (string.IsNullOrEmpty(doctor.specialty)) { message = "Doctor's specialty cannot be empty"; result = false; } return result; }
public bool UpdateDoctor(ref Doctor doctor, ref string message) { var result = true; if (!DoctorCheck(ref doctor, ref message)) { result = false; } else { try { var doctorBDO = new DoctorBDO(); TranslateDoctorDTOToDoctorBDO(doctor, doctorBDO); result = doctorLogic.UpdateDoctor( ref doctorBDO, ref message); doctor.RowVersion = doctorBDO.RowVersion; } catch (Exception e) { var msg = e.Message; throw new FaultException<DoctorFault> (new DoctorFault(msg), msg); } } return result; }
public void TranslateDoctorDTOToDoctorBDO( Doctor doctor, DoctorBDO doctorBDO) { doctorBDO.id = doctor.id; doctorBDO.firstName = doctor.firstName; doctorBDO.lastName = doctor.lastName; doctorBDO.city = doctor.city; doctorBDO.zip = doctor.zip; doctorBDO.street = doctor.street; doctorBDO.streetNr = doctor.streetNr; doctorBDO.phoneNr = doctor.phoneNr; doctorBDO.specialty = doctor.specialty; doctorBDO.description = doctor.description; doctorBDO.login = doctor.login; doctorBDO.pass = doctor.pass; doctorBDO.RowVersion = doctor.RowVersion; }
public Doctor GetDoctorByName(string name) { DoctorBDO doctorBDO = null; try { doctorBDO = doctorLogic.GetDoctorByName(name); } catch (Exception e) { var msg = e.Message; var reason = "GetDoctor exception"; throw new FaultException<DoctorFault> (new DoctorFault(msg), reason); } if (doctorBDO == null) { var msg = string.Format("No doctor found for id {0}", name); var reason = "GetDoctor empty"; throw new FaultException<DoctorFault> (new DoctorFault(msg), reason); } var doctor = new Doctor(); TranslateDoctorBDOToDoctorDTO(doctorBDO, doctor); return doctor; }