예제 #1
0
        public List <DoctorDto> GetAll()
        {
            List <DoctorDto> myDoctors = new List <DoctorDto>();

            _dbContext.Doctors.ToList().ForEach(doctor => myDoctors.Add(DoctorAdapter.DoctorToDoctorDto(doctor)));

            return(myDoctors);
        }
예제 #2
0
        public List <DoctorDto> GetByType(DoctorType type)
        {
            List <DoctorDto> myDoctors = new List <DoctorDto>();
            List <Doctor>    doctors   = _dbContext.Doctors.Where(doctor => doctor.Type == type).ToList();

            doctors.ForEach(doctor => myDoctors.Add(DoctorAdapter.DoctorToDoctorDto(doctor)));

            return(myDoctors);
        }
예제 #3
0
        public DoctorDto GetGeneralPractitioner(int patientId)
        {
            Patient myPatient = _dbContext.Patients.FirstOrDefault(patient => patient.Id == patientId);

            if (myPatient == null)
            {
                return(null);
            }

            return(DoctorAdapter.DoctorToDoctorDto(myPatient.GeneralPractitioner));
        }
예제 #4
0
        public DoctorDto GetById(int doctorId)
        {
            Doctor myDoctor = _dbContext.Doctors.SingleOrDefault(doctor => doctor.Id == doctorId);

            if (myDoctor == null)
            {
                return(null);
            }

            return(DoctorAdapter.DoctorToDoctorDto(myDoctor));
        }
예제 #5
0
        public DoctorDto Add(DoctorDto doctorDto)
        {
            if (doctorDto == null)
            {
                return(null);
            }

            Doctor doctor = DoctorAdapter.DoctorDtoToDoctor(doctorDto);

            _dbContext.Doctors.Add(doctor);
            _dbContext.SaveChanges();

            return(doctorDto);
        }
예제 #6
0
        public DoctorDto GetSpecialist(int patientId)
        {
            Patient myPatient = _dbContext.Patients.FirstOrDefault(patient => patient.Id == patientId);

            if (myPatient == null || myPatient.Referral == null || myPatient.Referral.IsDeleted)
            {
                return(null);
            }

            if (_dbContext.Doctors.FirstOrDefault(doctor => doctor.Id == myPatient.Referral.SpecialistId) == null)
            {
                return(null);
            }

            return(DoctorAdapter.DoctorToDoctorDto(_dbContext.Doctors.FirstOrDefault(doctor => doctor.Id == myPatient.Referral.SpecialistId)));
        }