コード例 #1
0
        public void AddTemplateQuestion(TestTemplate template, Guid questionId)
        {
            var question = FetchQuestion(questionId);

            if (question.IsInTestTemplate(template))
                throw new BusinessRuleException("Question already exists in the test template");
            else if (!question.Isvalid)
                throw new BusinessRuleException("Question does not contain either at least 2 choices or 1 choice with answer");
            else
                question.AddToTemplate(template);
        }
コード例 #2
0
 public TestInstance UpdateTestInstance(Guid instanceId, TestTemplate newTestTemplate, bool isPractice, int timeLimit)
 {
     var result = FetchTestInstance(instanceId);
     if (!result.IsOpen)
     {
         throw new BusinessRuleException("Unable to update once Test Instance is Open.");
     }
     result.TestTemplate = newTestTemplate;
     result.IsPractice = isPractice;
     result.TimeLimit = timeLimit;
     return result;
 }
コード例 #3
0
        public void RemoveTemplateQuestion(TestTemplate template, Guid questionId)
        {
            var question = FetchQuestion(questionId);

            if (question.IsInTestTemplate(template))
                question.RemoveFromTemplate(template);
            else
                throw new RecordNotFoundException("Question does not exists in the template");
        }
コード例 #4
0
 public List<Question> FetchQuestionsNotInTheTestTemplate(TestTemplate template)
 {
     return Questions.Where(q => !q.TestTemplates.Contains(template)).ToList();
 }
コード例 #5
0
 public void AddToTemplate(TestTemplate template)
 {
     TestTemplates.Add(template);
 }
コード例 #6
0
 public void RemoveFromTemplate(TestTemplate template)
 {
     TestTemplates.Remove(template);
 }
コード例 #7
0
 public bool IsInTestTemplate(TestTemplate template)
 {
     return TestTemplates.FirstOrDefault(t => t.Id.Equals(template.Id)) != null ? true : false;
 }
コード例 #8
0
 public void DeleteTestTemplate(Action action, TestTemplate template)
 {
     if (template.IsBeingUsedInTestInstance)
         throw new BusinessRuleException("Unable to update Test Template because it is being used in a Test Instance");
     action();
 }
コード例 #9
0
 public TestTemplate CreateTestTemplate(string name)
 {
     try
     {
         return FetchTestTemplate(name);
         throw new BusinessRuleException("Test Template name already exists");
     }
     catch (RecordNotFoundException)
     {
         var template = new TestTemplate(name);
         TestTemplates.Add(template);
         return template;
     }
 }
コード例 #10
0
ファイル: Facade.cs プロジェクト: uminfaa02/TestViewerDomain
 private void deleteTestTemplate(TestTemplate template)
 {
     template.Questions.Clear();
     _context.TestTemplates.Remove(template);
 }