コード例 #1
0
        public static TestItemListViewModel FromTest(Test test, string htmlLinks)
        {
            var model = FromTest(test);
            model.Action = new HtmlString(htmlLinks);

            return model;
        }
コード例 #2
0
 public static TestItemListViewModel FromTest(Test test)
 {
     return new TestItemListViewModel
     {
         Id = test.Id,
         Title = test.Title,
         Unlocked = test.Unlocked,
         HasQuestions = test.Questions.Count > 0
     };
 }
コード例 #3
0
 public Test SaveTest(Test test)
 {
     CheckForTestIsNotLocked(test.Id);
     ValidateTest(test);
     using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
     {
         repositoriesContainer.TestsRepository.Save(test);
         repositoriesContainer.ApplyChanges();
         return test;
     }
 }
コード例 #4
0
ファイル: TestViewModel.cs プロジェクト: slaq777/lmsystem
 public static TestViewModel FromTest(Test test)
 {
     return new TestViewModel
     {
         Id = test.Id,
         SubjectId = test.SubjectId,
         Title = test.Title,
         Description = test.Description,
         TimeForCompleting = test.TimeForCompleting,
         SetTimeForAllTest = test.SetTimeForAllTest,
         ForSelfStudy = test.ForSelfStudy,
         CountOfQuestions = test.CountOfQuestions,
         IsNecessary = test.IsNecessary
     };
 }
コード例 #5
0
        private void ValidateTest(Test test)
        {
            if (test.CountOfQuestions <= 0)
            {
                throw new InvalidDataException("Количество вопросов должно быть больше нуля");
            }

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                if (repositoriesContainer.TestsRepository.GetAll(new Query<Test>(t => t.Id != test.Id && t.Title == test.Title && t.SubjectId == test.SubjectId)).Any())
                {
                    throw new InvalidDataException("Тест с таким названием уже существует в рамках данного предмета");
                }
            }
        }