// GET: PatientViewAssignment public ActionResult Index() { string username = System.Web.HttpContext.Current.User.Identity.Name; Patient findPatient = db.Patients.SingleOrDefault(p => p.Patient_Email == username); int patientID = findPatient.PatientID; Assignment assignment = db.Assignments.SingleOrDefault(a => a.PatientID == patientID); Therapist therapist = db.Therapists.SingleOrDefault(t => t.TherapistID == assignment.TherapistID); ExerciseInstruction eI = db.ExerciseInstructions.SingleOrDefault(e => e.AssignmentID == assignment.AssignmentID); AssignedVideo aV = db.AssignedVideos.SingleOrDefault(a => a.ExerciseInstructionID == eI.ExerciseInstructionID); ExerciseVideo eV = db.ExerciseVideos.SingleOrDefault(e => e.ExerciseVideoID == aV.ExerciseVideoID); Exercise exercise = db.Exercises.SingleOrDefault(e => e.ExerciseID == eV.ExerciseID); ExerciseRegion region = db.ExerciseRegions.SingleOrDefault(c => c.ExerciseRegionID == exercise.ExerciseRegionID); ViewBag.assignment = assignment.AssignmentID; ViewBag.therapist = therapist.Name; ViewBag.Number_Of_Reps = eI.Number_Of_Reps; ViewBag.Frequency_Per_Day = eI.Frequency_Per_Day; ViewBag.Remark = eI.Remark; ViewBag.eV = eV.VideoURL; ViewBag.exerciseName = exercise.Name; ViewBag.cat = region.Name; return(View()); }
public ActionResult DeleteConfirmed(int id) { ExerciseInstruction exerciseInstruction = db.ExerciseInstructions.Find(id); db.ExerciseInstructions.Remove(exerciseInstruction); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ExerciseInstructionID,Number_Of_Reps,Frequency_Per_Day,Reps_Completed,Remark,AssignmentID")] ExerciseInstruction exerciseInstruction) { if (ModelState.IsValid) { db.Entry(exerciseInstruction).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AssignmentID = new SelectList(db.Assignments, "AssignmentID", "AssignmentID", exerciseInstruction.AssignmentID); return(View(exerciseInstruction)); }
// GET: ExerciseInstructions/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExerciseInstruction exerciseInstruction = db.ExerciseInstructions.Find(id); if (exerciseInstruction == null) { return(HttpNotFound()); } return(View(exerciseInstruction)); }
// GET: ExerciseInstructions/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExerciseInstruction exerciseInstruction = db.ExerciseInstructions.Find(id); if (exerciseInstruction == null) { return(HttpNotFound()); } ViewBag.AssignmentID = new SelectList(db.Assignments, "AssignmentID", "AssignmentID", exerciseInstruction.AssignmentID); return(View(exerciseInstruction)); }
public ActionResult AssignExercisesViewModel(List <AssignExercisesViewModel> aE, int pID) { if (ModelState.IsValid) { foreach (var i in aE) { //create assignment Assignment assignment = new Assignment(); assignment.Date_Assigned = DateTime.Now; assignment.PatientID = pID; Patient patient = db.Patients.Find(pID); string email = User.Identity.GetUserName(); Therapist therapist = db.Therapists.SingleOrDefault(T => T.Email == email); assignment.TherapistID = therapist.TherapistID; db.Assignments.Add(assignment); db.SaveChanges(); //create Exercise Instruction ExerciseInstruction exerciseInstruction = new ExerciseInstruction(); exerciseInstruction.Number_Of_Reps = i.Number_Of_Reps; exerciseInstruction.Frequency_Per_Day = i.Frequency_Per_Day; exerciseInstruction.Remark = i.Remark; exerciseInstruction.Reps_Completed = 0; exerciseInstruction.AssignmentID = assignment.AssignmentID; db.ExerciseInstructions.Add(exerciseInstruction); db.SaveChanges(); //create assignedVideo AssignedVideo assignedVideo = new AssignedVideo(); assignedVideo.ExerciseInstructionID = exerciseInstruction.ExerciseInstructionID; ExerciseVideo eV = db.ExerciseVideos.SingleOrDefault(e => e.ExerciseID == i.ExerciseID); assignedVideo.ExerciseVideoID = eV.ExerciseVideoID; db.AssignedVideos.Add(assignedVideo); db.SaveChanges(); return(RedirectToAction("Index", "AssignExercisesViewModel")); } } return(View(aE)); }