Example #1
0
        public List <PatientDto> GetAll()
        {
            List <PatientDto> myPatients = new List <PatientDto>();

            _dbContext.Patients.ToList().ForEach(patient => myPatients.Add(PatientAdapter.PatientToPatientDto(patient)));

            return(myPatients);
        }
        public IActionResult Add(Patient patient)
        {
            if (_patientService.Add(patient) == null)
            {
                return(NotFound());
            }

            return(Ok(PatientAdapter.PatientToPatientDto(patient)));
        }
Example #3
0
        public PatientDto GetById(int patientId)
        {
            Patient patient = _dbContext.Patients.SingleOrDefault(p => p.Id == patientId);

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

            return(PatientAdapter.PatientToPatientDto(patient));
        }
Example #4
0
        public PatientDto GetAppointmentPatient(int appointmentId)
        {
            Appointment appointment = _dbContext.Appointments.SingleOrDefault(appointment => appointment.Id == appointmentId);
            Patient     myPatient   = _dbContext.Patients.SingleOrDefault(patient => patient.Id == appointment.PatientId);

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

            return(PatientAdapter.PatientToPatientDto(myPatient));
        }
Example #5
0
        public PatientDto SetGeneralPractitioner(int patientId, int doctorId)
        {
            Patient myPatient = _dbContext.Patients.SingleOrDefault(patient => patient.Id == patientId);

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

            myPatient.GeneralPractitioner = _dbContext.Doctors.SingleOrDefault(doctor => doctor.Id == doctorId);
            _dbContext.SaveChanges();

            return(PatientAdapter.PatientToPatientDto(myPatient));
        }
Example #6
0
        public PatientDto Add(Patient patient)
        {
            if (patient == null || patient.Password == null)
            {
                return(null);
            }

            if (_dbContext.Patients.SingleOrDefault(p => p.Username == patient.Username) != null)
            {
                return(null);
            }

            GiveRandomGeneralPractitioner(patient);
            _dbContext.Patients.Add(patient);
            _dbContext.SaveChanges();

            return(PatientAdapter.PatientToPatientDto(patient));
        }