/// <summary>
 /// Maps a DB prescription to a model one.
 /// </summary>
 /// <param name="script"></param>
 /// <returns></returns>
 internal static Models.Prescription MapPrescription(DataModel.Prescription script)
 {
     return(new Models.Prescription(script.Id, script.Information, script.Drug)
     {
         PatientId = script.PatientId,
         DoctorId = script.DoctorId
     });
 }
Esempio n. 2
0
        /// <summary>
        /// Add a prescription to the database
        /// </summary>
        /// <param name="prescription">The prescition to be added to the databse</param>
        public Models.Prescription AddPrescription(Models.Prescription prescription)
        {
            var newPrescription = new DataModel.Prescription
            {
                Information = prescription.Info,
                Drug        = prescription.DrugName,
                PatientId   = prescription.PatientId,
                DoctorId    = prescription.DoctorId
            };

            _context.Add(newPrescription);
            _context.SaveChanges();
            prescription.Id = newPrescription.Id;
            return(prescription);
        }
Esempio n. 3
0
        /// <summary>
        /// Add a prescription to the database
        /// </summary>
        /// <param name="prescription">The prescition to be added to the databse</param>
        public async Task <Models.Prescription> AddPrescriptionAsync(Models.Prescription prescription)
        {
            var newPrescription = new DataModel.Prescription
            {
                Information = prescription.Info,
                Drug        = prescription.DrugName,
                PatientId   = prescription.PatientId,
                DoctorId    = prescription.DoctorId,
            };

            await _context.AddAsync(newPrescription);

            await _context.SaveChangesAsync();

            prescription.Id = newPrescription.Id;
            return(prescription);
        }