コード例 #1
0
 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;
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
        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;
        }
コード例 #6
0
 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;
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 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;
 }