Esempio n. 1
0
        /// <summary>
        /// Get's a specific patient based on their ID
        /// </summary>
        /// <exception cref="ArgumentException">
        /// Throws an argument exception if there is no patient with that ID in the DB.
        /// </exception>
        /// <param name="patientId">The patient's ID in the database.</param>
        /// <returns>A model representation of that patient.</returns>
        public Models.Patient GetPatientByID(int patientId)
        {
            var DBPatient = _context.Patients.Find(patientId);

            if (DBPatient is not null)
            {
                return(DB_DomainMapper.MapPatient(DBPatient));
            }
            else
            {
                throw new ArgumentException("Patient Not found in DB.");
            }
        }
Esempio n. 2
0
        public async Task <Models.Patient> GetPatientByIDAsync(int patientId)
        {
            var DBPatient = await _context.Patients.FindAsync(patientId);

            if (DBPatient is not null)
            {
                return(DB_DomainMapper.MapPatient(DBPatient));
            }
            else
            {
                throw new ArgumentException("Patient Not found in DB.");
            }
        }
Esempio n. 3
0
        public async Task <IEnumerable <Models.Patient> > GetPatientsAsync()
        {
            var DBPatients = await _context.Patients
                             .Include(thing => thing.PatientReports)
                             .ToListAsync();

            List <Models.Patient> ModelPatients = new List <Models.Patient>();

            foreach (var dbpatient in DBPatients)
            {
                ModelPatients.Add(DB_DomainMapper.MapPatient(dbpatient));
            }

            return(ModelPatients);
        }