Exemplo n.º 1
0
        public ConsultationEntity GetConsultationsById(int id)
        {
            Consultation daConsultation = _dataAccessService.ConsultationRepository.GetItemById(id);

            if (daConsultation == null)
            {
                return(null);
            }
            return(DTOMapper.Convert(daConsultation));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Return a patient entity for a given ID
        /// </summary>
        /// <param name="id">Patient ID</param>
        /// <returns></returns>
        public PatientEntity GetPatientById(int id)
        {
            var daPatient = _dataAccessService.GetPatientById(id);

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

            //convert Patient to PatientEntity
            return(DTOMapper.Convert(daPatient));
        }
Exemplo n.º 3
0
        public List <ConsultationEntity> GetConsultationsByConsultaionDate(DateTime consultaionDate)
        {
            List <Consultation> daConsultations = _dataAccessService.GetAllConsultationsByConsultaionDate(consultaionDate);

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

            if (daConsultations.Count == 0)
            {
                return(new List <ConsultationEntity>());
            }

            return(DTOMapper.Convert(daConsultations));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get all patients
        /// </summary>
        /// <returns></returns>
        public List <PatientEntity> GetAllPatients()
        {
            List <Patient> daPatients = _dataAccessService.GetAllPatients();

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

            if (daPatients.Count == 0)
            {
                return(new List <PatientEntity>());
            }

            //convert List<Patient> to List<PatientEntity>
            return(DTOMapper.Convert(daPatients));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Insert a patient
        /// </summary>
        /// <param name="newPatient"></param>
        /// <returns></returns>
        public PatientEntity AddPatient(PatientEntity newPatient)
        {
            if (newPatient == null)
            {
                throw new ArgumentNullException();
            }
            try
            {
                var daPatient = _dataAccessService.AddPatient(DTOMapper.Convert(newPatient));

                if (daPatient == null)
                {
                    throw new Exception("Create patient failed");
                }

                return(DTOMapper.Convert(daPatient));
            }
            catch
            {
                //log the error
                throw;
            }
        }