partial void DeleteExamConcreteTest(ExamConcreteTest instance);
 partial void UpdateExamConcreteTest(ExamConcreteTest instance);
 partial void InsertExamConcreteTest(ExamConcreteTest instance);
		private void detach_ExamConcreteTests(ExamConcreteTest entity)
		{
			this.SendPropertyChanging();
			entity.UserDetails = null;
		}
		private void attach_ExamConcreteTests(ExamConcreteTest entity)
		{
			this.SendPropertyChanging();
			entity.ExamTest = this;
		}
        public ActionResult TestFinish()
        {
            if (TestSession != null)
            {
                var result = TestSession.GetResult();
                var percentageResult = TestSession.GetPercentageResult();

                var concreteTest = new ExamConcreteTest();
                concreteTest.TestID = ActiveTest.ExamTestID;
                concreteTest.UserID = UserId;
                concreteTest.StartTime = (DateTime) Session["StartTime"];
                concreteTest.EndTime = DateTime.Now;
                concreteTest.Result = percentageResult;
                JournalContext.ExamConcreteTests.InsertOnSubmit(concreteTest);
                //JournalContext.SubmitChanges();

                foreach (var questionState in result)
                {
                    var qa = new ExamQuestionAnswer();
                    qa.ExamConcreteTest = concreteTest;
                    qa.QuestionID = questionState.Key.QuestionID;
                    qa.UserAnswer = questionState.Value.GetAnswers().Aggregate((a, b) => a + ' ' + b);
                    JournalContext.ExamQuestionAnswers.InsertOnSubmit(qa);
                }
                JournalContext.SubmitChanges();
                TestSession = null;
                return View(concreteTest);
            }

            return RedirectToAction("Index");
        }