Beispiel #1
0
        public async Task TakeTest(Guid testGuid)
        {
            TestCaseRepository testCaseRepo = new TestCaseRepository();
            var testCaseTask = testCaseRepo.GetByIdAsync(testGuid);

            ApplicationUserRepository <Tester> userRepo = new ApplicationUserRepository <Tester>();
            var testerTask = userRepo.GetByUserNameAsync(User.Identity.Name);

            DataAccess.Model.Tests.Tests tests = new DataAccess.Model.Tests.Tests();
            tests.Test    = await testCaseTask;
            tests.Status  = TestsStatus.Takened;
            tests.Takened = DateTime.Now;
            tests.Tester  = await testerTask;

            TestsRepository testsRepo = new TestsRepository();

            testsRepo.Create(tests);
        }
        public async Task TakeGroup(Guid groupId)
        {
            TestGroupRepository testGroupRepo = new TestGroupRepository();
            var testGroupTask = testGroupRepo.GetByIdAsync(groupId);

            ApplicationUserRepository <Tester> userRepo = new ApplicationUserRepository <Tester>();
            var testerTask = userRepo.GetByUserNameAsync(User.Identity.Name);

            TestGroups testGroups = new TestGroups();

            testGroups.TestGroup = await testGroupTask;
            testGroups.Status    = GroupStatus.Takened;
            testGroups.Takened   = DateTime.Now;
            testGroups.Tester    = await testerTask;

            TestGroup       testGroup = await testGroupTask;
            TestsRepository testsRepo = new TestsRepository();

            foreach (var testCase in testGroup.TestCases)
            {
                if (!testsRepo.IsTestTakened(testCase, await testerTask))
                {
                    DataAccess.Model.Tests.Tests tests = new DataAccess.Model.Tests.Tests();
                    tests.Test    = testCase;
                    tests.Status  = TestsStatus.Takened;
                    tests.Takened = DateTime.Now;
                    tests.Tester  = await testerTask;

                    testsRepo.Create(tests);
                }
            }

            TestGroupsRepository testGroupsRepo = new TestGroupsRepository();

            testGroupsRepo.Create(testGroups);
        }