Exemplo n.º 1
0
        public async Task <Models.Prescription> GetPrescriptionAsync(int PrescriptionId)
        {
            var script = await _context.Prescriptions.FindAsync(PrescriptionId);

            if (script is not null)
            {
                return(DB_DomainMapper.MapPrescription(script));
            }
            else
            {
                throw new ArgumentException($"Prescription, {PrescriptionId}, not found.");
            }
        }
Exemplo n.º 2
0
        /*    _____                         _       _   _
         *   |  __ \                       (_)     | | (_)
         *   | |__) | __ ___  ___  ___ _ __ _ _ __ | |_ _  ___  _ __  ___
         *   |  ___/ '__/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \/ __|
         *   | |   | | |  __/\__ \ (__| |  | | |_) | |_| | (_) | | | \__ \
         *   |_|   |_|  \___||___/\___|_|  |_| .__/ \__|_|\___/|_| |_|___/
         *                                   | |
         *                                   |_|
         */
        #region Prescriptions
        /// <summary>
        /// Get's a specific prescription by it's ID
        /// </summary>
        /// <exception cref="ArgumentException">
        /// Throws an argument exception if there is no perscription with that ID in the DB.
        /// </exception>
        /// <param name="PerscriptionId">The ID of the desired prescription</param>
        /// <returns>The prescription with the given ID.</returns>
        public Models.Prescription GetPrescription(int PrescriptionId)
        {
            var script = _context.Prescriptions.Find(PrescriptionId);

            if (script is not null)
            {
                return(DB_DomainMapper.MapPrescription(script));
            }
            else
            {
                throw new ArgumentException($"Prescription, {PrescriptionId}, not found.");
            }
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <Models.Prescription> > GetPatientPrescriptionsAsync(int patientID)
        {
            var DbPerscriptions = await _context.Prescriptions
                                  .Where(p => p.PatientId == patientID)
                                  .ToListAsync();

            List <Models.Prescription> modelPresciptions = new List <Models.Prescription>();

            foreach (var script in DbPerscriptions)
            {
                modelPresciptions.Add(DB_DomainMapper.MapPrescription(script));
            }

            return(modelPresciptions);
        }