public void Insert(DetailModel item) { Detail detail = new Detail { QuestionId = item.Question.QuestionId, TestId = item.TestId, }; _detailRepo.Insert(detail); item.DetailId = detail.DetailId; }
public FullTestModel GenerateTest(int count) { if (count < 10) count = 40; if (count > 100) count = 100; IList<SubjectModel> subjects = _subjectBus.Get(); IList<QuestionModel> questions; IList<QuestionModel> testQuestions = new List<QuestionModel>(); int countQuestion = count / subjects.Count; int remainCount = count % subjects.Count; IList<int> list; foreach (SubjectModel subject in subjects) { questions = _questionBus.FindBySubjectId(subject.SubjectId).Reduce(); int c = countQuestion + ((remainCount-- > 0) ? 1 : 0); list = RandUnique(0, questions.Count, c); foreach (int idx in list) { testQuestions.Add(questions[idx]); } } Test test = new Test { CreationTime = DateTime.Now, TotalQuestion = testQuestions.Count, TotalCorrect = 0, UserId = 1, FinalTime = null, }; _testRepo.Insert(test); foreach (QuestionModel question in testQuestions) { Detail detail = new Detail { QuestionId = question.QuestionId, TestId = test.TestId }; _detailBus.Insert(detail); } return FillTheTest(test); }
public void Insert(Detail item) { _detailRepo.Insert(item); }
partial void DeleteDetail(Detail instance);
partial void UpdateDetail(Detail instance);
partial void InsertDetail(Detail instance);