Пример #1
0
        public IActionResult Edit(int id)
        {
            Medication med = _context.Medication.Single(c => c.ID == id);

            // IEnumerable<ToD> times = (ToD[])Enum.GetValues(typeof(ToD));

            EditMedViewModel editMedViewModel = new EditMedViewModel(med);

            return(View(editMedViewModel));
        }
Пример #2
0
        public IActionResult EditPost(EditMedViewModel editMedViewModel)
        {
            string          user         = User.Identity.Name;
            ApplicationUser userLoggedIn = _context.Users.Single(c => c.UserName == user);

            Medication editedMed = _context.Medication.Single(c => c.ID == editMedViewModel.Med.ID);

            editedMed.Name       = editMedViewModel.Med.Name;
            editedMed.Dosage     = editMedViewModel.Med.Dosage;
            editedMed.Notes      = editMedViewModel.Med.Notes;
            editedMed.TimesXDay  = editMedViewModel.Med.TimesXDay;
            editedMed.RefillRate = editMedViewModel.Med.RefillRate;
            editedMed.UserID     = userLoggedIn.Id;

            // update change and save to db
            _context.Medication.Update(editedMed);
            _context.SaveChanges();

            return(Redirect("/Medications/Index"));
        }
Пример #3
0
        public IActionResult EditPost(int id, EditMedViewModel editMedViewModel)
        {
            Medication editedMed = context.Medication.Single(c => c.ID == id);

            editedMed.Name   = editMedViewModel.Med.Name;
            editedMed.Dosage = editMedViewModel.Med.Dosage;
            editedMed.Notes  = editMedViewModel.Med.Notes;
            //editedMed.TimesXDay = editMedViewModel.Med.TimesXDay;
            editedMed.TimeOfDay         = editMedViewModel.SelectedTime;
            editedMed.Description       = editMedViewModel.Med.Description;
            editedMed.RefillRate        = editMedViewModel.Med.RefillRate;
            editedMed.Pharmacy          = editMedViewModel.Med.Pharmacy;
            editedMed.PrescribingDoctor = editMedViewModel.Med.PrescribingDoctor;
            editedMed.ScripNumber       = editMedViewModel.Med.ScripNumber;
            editedMed.PillsPerDose      = editMedViewModel.Med.PillsPerDose;

            // update change and save to db
            context.Medication.Update(editedMed);
            context.SaveChanges();

            return(Redirect("/Medication/Index"));
        }