// GET: Patient/Edit/5
        public ActionResult Create(FormCollection collection)
        {
            string MedicineName = collection.Get("name");
            var    patient      = (Patient)TempData["patient"];
            var    doctor       = (Doctor)TempData["doctor"];

            DateTime          start             = DateTime.Parse(collection.Get("start"));
            DateTime          end               = DateTime.Parse(collection.Get("end"));
            var               prescription      = (Prescription)TempData["prescription"];
            var               MedicinesNames    = (SelectList)TempData["MedicineNames"];
            MedicineModel     medicineModel     = new MedicineModel();
            PrescriptionModel prescriptionModel = new PrescriptionModel();

            MedicineTimes        medicine  = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end);
            List <MedicineTimes> medicines = new List <MedicineTimes>();


            prescriptionModel.AddMedicine(medicines, medicine);
            PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines);

            ViewBag.MedicineNames    = MedicinesNames;
            TempData["viewModel"]    = viewModel;
            TempData["prescription"] = prescription;
            TempData["doctor"]       = doctor;
            TempData["medicines"]    = medicines;
            return(RedirectToAction("Edit"));
        }
        public ActionResult Edit(FormCollection collection)
        {
            var      doctor       = (Doctor)TempData["doctor"];
            var      patient      = (Patient)TempData["patient"];
            var      medicines    = (List <MedicineTimes>)TempData["medicines"];
            var      prescription = (Prescription)TempData["prescription"];
            string   MedicineName = collection.Get("name");
            DateTime start        = new DateTime();
            DateTime end          = new DateTime();

            if (!DateTime.TryParse(collection.Get("start"), out start) && !DateTime.TryParse(collection.Get("end"), out end) || MedicineName == "" && Request.Form["Add"] == null)
            {
                TempData["prescription"] = prescription;
                TempData["medicines"]    = medicines;
                return(RedirectToAction("Check", "Interactions"));
            }

            var               MedicinesNames    = (SelectList)TempData["MedicineNames"];
            MedicineModel     medicineModel     = new MedicineModel();
            PrescriptionModel prescriptionModel = new PrescriptionModel();
            MedicineTimes     medicine          = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end);

            //PrescriptionMedicine rm = new PrescriptionMedicine(patient.TZ,MedicineNames, start, end);
            prescriptionModel.AddMedicine(medicines, medicine);
            PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines);

            ViewBag.MedicineNames = MedicinesNames;
            TempData["viewModel"] = viewModel;

            return(RedirectToAction("Edit"));
        }