Exemple #1
0
        public IActionResult AddMedication(int PatientId)
        {
            var model = new AddMedicationVM();

            var user = _context.Patient.First(u => u.Id == PatientId);

            model.DOB         = user.Dob;
            model.PatientId   = PatientId;
            model.PatientName = user.FirstName + " " + user.LastName;
            model.Medication  = new Medications();

            return(View(model));
        }
Exemple #2
0
        public async Task <IActionResult> AddMedication(AddMedicationVM model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("AddMedication", new { PatientId = model.PatientId }));
            }
            model.Medication.PatientId = model.PatientId;
            model.Medication.Active    = true;
            model.Medication.Approved  = false;
            model.Medication.DateTime  = DateTime.Now;
            _context.Medications.Add(model.Medication);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Medications", new { PatientId = model.PatientId }));
        }