public void CreteQuestionOutcome(QuestionOutcomeModel model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(databaseName))) { var p = new DynamicParameters(); p.Add("@QuestionId", model.QuestionId); p.Add("@CourseOutcomeId", model.CourseOutcomeId); p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("dbo.spQuestionOutcomes_Insert", p, commandType: CommandType.StoredProcedure); model.Id = p.Get <int>("@id"); } }
private void CreateExamBtn_Click(object sender, RoutedEventArgs e) { if (ValidForm()) { Exam.ExamType = (ExamTypeModel)examTypesCombobox.SelectedItem; Exam.Date = (DateTime)examDate.SelectedDate; GlobalConfig.Connection.CreateExam(Exam); foreach (ExamGroupModel examGroup in Exam.ExamGroups) { examGroup.ExamId = Exam.Id; GlobalConfig.Connection.CreateExamGroup(examGroup); AnswerKeyModel answerKey = Evaluator.AnswerKeys.Find(a => a.Group.Name == examGroup.Group.Name); int counter = 0; foreach (QuestionModel question in examGroup.Questions) { question.ExamGroupId = examGroup.Id; GlobalConfig.Connection.CreateQuestion(question); foreach (var studentAnswers in Evaluator.StudentsAnswers) { if (studentAnswers.Group.Name == answerKey.Group.Name) { ResultModel r = new ResultModel { QuestionId = question.Id }; StudentModel model = GlobalConfig.Connection.GetStudent_ByRegNo(studentAnswers.Student.RegNo); r.Student = model; if (studentAnswers.AnswersList[counter].ToString() == answerKey.AnswersList.Substring(counter, 1)) { r.IsTrue = true; } else { r.IsTrue = false; } GlobalConfig.Connection.CreateResult(r); } } counter++; foreach (CourseOutcomeModel courseOutcome in question.QuestionOutcomes) { QuestionOutcomeModel model = new QuestionOutcomeModel(); model.CourseOutcomeId = courseOutcome.Id; model.QuestionId = question.Id; GlobalConfig.Connection.CreteQuestionOutcome(model); } } } CallingWindow.ExamComplete(Exam); this.Close(); } }