コード例 #1
0
        public ActionResult Create([Bind(Include = "PatientID,PatientFName,PatientSName,PatientEmail,PatientLoginCode,PatientPass")] Patient patient)
        {
            if (ModelState.IsValid)
            {
                db.Patients.Add(patient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(patient));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "ConditionID,PatientID,Condition1,ConditionNotes")] Condition condition)
        {
            if (ModelState.IsValid)
            {
                db.Conditions.Add(condition);
                db.SaveChanges();
                return(RedirectToAction("Dashboard", "Home", new { area = "Home" }));
            }

            ViewBag.PatientID = new SelectList(db.Patients, "PatientID", "PatientFName", condition.PatientID);
            return(View(condition));
        }
コード例 #3
0
 public ActionResult EditPatient([Bind(Include = "PatientID,PatientFName,PatientSName,PatientEmail,PatientLoginCode,PatientPass")] Patient patient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(patient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("PatientHome", "Home", new { @area = "Home" }));
     }
     return(View(patient));
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "SurveyID,DoctorID,PatientID,SurveyTitle,SurveyFreq,SurveyDesc,SurveyQuestionAmount")] Survey survey)
        {
            if (ModelState.IsValid)
            {
                db.Surveys.Add(survey);
                db.SaveChanges();

                //Creates Session based on Survey ID -
                //Used to ensure that you are creating questions for right survey
                Session["SurveyID"]    = survey.SurveyID.ToString();
                Session["SurveyTitle"] = survey.SurveyTitle.ToString();

                //Creates Session based on Survey Question Amount
                Session["SurveyQuestionAmount"] = survey.SurveyQuestionAmount.ToString();

                return(RedirectToAction("Create", "Questions", new { area = "Questions" }));
            }

            ViewBag.DoctorID  = new SelectList(db.Doctors, "DoctorID", "DoctorFName", survey.DoctorID);
            ViewBag.PatientID = new SelectList(db.Patients, "PatientID", "PatientFName", survey.PatientID);
            return(View(survey));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "QuestionID,SurveyID,Question1,QuestionType")] Question question)
        {
            if (ModelState.IsValid)
            {
                db.Questions.Add(question);
                db.SaveChanges();

                //Counts amount of Questions Created
                Session["QuestionAmount"] = Convert.ToInt32(Session["QuestionAmount"]) + 1;

                //Redirect to AnswersController if the QuestionType isn't these specified question types
                if (question.QuestionType == "Free Text" || question.QuestionType == "True Or False")
                {
                    Session["QuestionID"] = Convert.ToString(question.QuestionID);

                    //Update QuestionAnswer table with dummy data since these types of questions don't need specific answers
                    string        mainConn = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                    SqlConnection sqlConn  = new SqlConnection(mainConn);
                    string        query    = "INSERT INTO [dbo].QuestionAnswers VALUES (@QuestionID, @QuestionAnswer)";
                    SqlCommand    sqlComm  = new SqlCommand(query, sqlConn);
                    sqlConn.Open();
                    sqlComm.Parameters.AddWithValue("@QuestionID", Convert.ToInt32(Session["QuestionID"]));
                    sqlComm.Parameters.AddWithValue("@QuestionAnswer", "N/A");
                    sqlComm.ExecuteNonQuery();
                    sqlConn.Close();

                    return(RedirectToAction("Create"));
                }

                if (question.QuestionType == "Numeric Answer")
                {
                    Session["QuestionID"] = Convert.ToString(question.QuestionID);

                    //Update QuestionAnswer table with dummy data since these types of questions don't need specific answers
                    string        mainConn = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                    SqlConnection sqlConn  = new SqlConnection(mainConn);
                    string        query    = "INSERT INTO [dbo].QuestionAnswers VALUES (@QuestionID, @QuestionAnswer)";
                    SqlCommand    sqlComm  = new SqlCommand(query, sqlConn);
                    sqlConn.Open();
                    sqlComm.Parameters.AddWithValue("@QuestionID", Convert.ToInt32(Session["QuestionID"]));
                    sqlComm.Parameters.AddWithValue("@QuestionAnswer", "N/A");
                    sqlComm.ExecuteNonQuery();
                    sqlConn.Close();

                    return(RedirectToAction("RuleParameters"));
                }

                //Redirect to a page where you can upload an audio or video file
                if (question.QuestionType == "Audio")
                {
                    Session["QuestionType"] = Convert.ToString(question.QuestionType);
                    Session["QuestionID"]   = Convert.ToString(question.QuestionID);
                    Session["Question"]     = Convert.ToString(question.Question1);

                    return(RedirectToAction("UploadAudio"));
                }

                if (question.QuestionType == "Video")
                {
                    Session["QuestionType"] = Convert.ToString(question.QuestionType);
                    Session["QuestionID"]   = Convert.ToString(question.QuestionID);
                    Session["Question"]     = Convert.ToString(question.Question1);

                    return(RedirectToAction("UploadVideo"));
                }

                else
                {
                    //Create session type in order to modify the appearance of the QuestionAnswers view
                    Session["QuestionType"] = Convert.ToString(question.QuestionType);
                    Session["QuestionID"]   = Convert.ToString(question.QuestionID);
                    Session["Question"]     = Convert.ToString(question.Question1);

                    return(RedirectToAction("Create", "QuestionAnswers", new { area = "QuestionAnswers" }));
                }
            }

            if (Convert.ToInt32(Session["QuestionAmount"]) == Convert.ToInt32(Session["SurveyQuestionAmount"]))
            {
                return(RedirectToAction("ReviewSurvey", "Surveys", new { area = "Surveys" }));
            }

            ViewBag.SurveyID = new SelectList(db.Surveys, "SurveyID", "SurveyTitle", question.SurveyID);
            return(View(question));
        }
        public ActionResult Create([Bind(Include = "QuestionAnswerID,QuestionID,QuestionAnswer1")] QuestionAnswer questionAnswer)
        {
            if (ModelState.IsValid)
            {
                db.QuestionAnswers.Add(questionAnswer);
                db.SaveChanges();

                if (Session["QuestionType"].ToString() == "Multiple Choice")
                {
                    Session["QuestionAnswerAmount"] = Convert.ToInt32(Session["QuestionAnswerAmount"]) + 1;

                    if (Convert.ToInt32(Session["QuestionAnswerAmount"]) < 4)
                    {
                        return(RedirectToAction("Create"));
                    }
                    else
                    {
                        Session.Remove("QuestionAnswerAmount");
                        Session.Remove("QuestionID");
                        Session.Remove("Question");

                        return(RedirectToAction("Create", "Questions", new { @area = "Questions" }));
                    }
                }

                //if(Session["QuestionType"].ToString() == "Audio")
                //{
                //    Session["QuestionAnswerAmount"] = Convert.ToInt32(Session["QuestionAnswerAmount"]) + 1;

                //    if (Request.Files.Count > 0)
                //    {
                //        var file = Request.Files[0];

                //        if (file != null && file.ContentLength > 0)
                //        {
                //            var fileName = Path.GetFileName(file.FileName);
                //            var filePath = Path.Combine(Server.MapPath("~/Audio/"), fileName);
                //            file.SaveAs(filePath);

                //            Session.Remove("QuestionAnswerAmount");
                //            Session.Remove("QuestionID");
                //            Session.Remove("Question");

                //            return RedirectToAction("Create", "Questions", new { @area = "Questions" });
                //        }
                //    }
                //}

                //if(Session["QuestionType"].ToString() == "Video")
                //{
                //    Session["QuestionAnswerAmount"] = Convert.ToInt32(Session["QuestionAnswerAmount"]) + 1;

                //    if (Request.Files.Count > 0)
                //    {
                //        var file = Request.Files[0];

                //        if (file != null && file.ContentLength > 0)
                //        {
                //            var fileName = Path.GetFileName(file.FileName);
                //            var filePath = Path.Combine(Server.MapPath("~/Video/"), fileName);
                //            file.SaveAs(filePath);

                //            Session.Remove("QuestionAnswerAmount");
                //            Session.Remove("QuestionID");
                //            Session.Remove("Question");

                //            return RedirectToAction("Create", "Questions", new { @area = "Questions" });
                //        }
                //    }
                //}

                return(RedirectToAction("Index"));
            }

            ViewBag.QuestionID = new SelectList(db.Questions, "QuestionID", "Question1", questionAnswer.QuestionID);
            return(View(questionAnswer));
        }