Beispiel #1
0
        public async Task <IActionResult> GetTestAttendeeByIdAsync([FromRoute] int testId, [FromRoute] bool isPreview)
        {
            if (!await _testRepository.IsTestExists(testId))
            {
                return(NotFound());
            }

            await HttpContext.Session.LoadAsync();

            if (HttpContext.Session.GetInt32(_stringConstants.AttendeeIdSessionKey) == null && !isPreview)
            {
                return(NotFound());
            }
            var attendeeId = HttpContext.Session.GetInt32(_stringConstants.AttendeeIdSessionKey).Value;

            if (!await IsAttendeeValid(attendeeId))
            {
                return(NotFound());
            }
            var testAttendee = await _testConductRepository.GetTestAttendeeByIdAsync(attendeeId);

            if (testAttendee.Report != null && (testAttendee.Report.TestStatus == TestStatus.BlockedTest || testAttendee.Report.TestStatus == TestStatus.ExpiredTest))
            {
                HttpContext.Session.SetString(_stringConstants.Path, "");
            }
            return(Ok(testAttendee));
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateTestNameAsync([FromRoute] int id, [FromBody] Test testObject)
        {
            if (!ModelState.IsValid || testObject == null || !await _testRepository.IsTestEditableAsync(id))
            {
                return(BadRequest());
            }
            if (!await _testRepository.IsTestExists(id))
            {
                return(NotFound());
            }
            await _testRepository.UpdateTestNameAsync(id, testObject);

            return(Ok(testObject));
        }
Beispiel #3
0
        public async Task IsTestExists()
        {
            string userName = "******";
            //Configuring Application User
            ApplicationUser user = new ApplicationUser()
            {
                Email = userName, UserName = userName
            };
            await _userManager.CreateAsync(user);

            var applicationUser = await _userManager.FindByEmailAsync(user.Email);

            var category = CreateCategory("category Name");
            await _categoryRepository.AddCategoryAsync(category);

            var testCategoryAC = new List <TestCategoryAC>
            {
                new TestCategoryAC()
                {
                    CategoryId = category.Id,
                    IsSelect   = true,
                }
            };
            //Creating Test
            var test = CreateTest("English");
            await _testRepository.CreateTestAsync(test, applicationUser.Id);

            await _testRepository.GetTestByIdAsync(test.Id, applicationUser.Id);

            var result = await _testRepository.IsTestExists(test.Id);

            Assert.True(result);
        }