예제 #1
0
        public async Task <TestInstructionsAC> GetTestInstructionsAsync(string testLink)
        {
            var testObject = await _dbContext.Test.Where(x => x.Link == testLink)
                             .Include(x => x.TestQuestion).ToListAsync();

            if (testObject.Any())
            {
                var testInstructionsDetails = testObject.First();
                var totalNumberOfQuestions  = testInstructionsDetails.TestQuestion.Count();
                var testCategoryANameList   = new List <string>();
                var testByIdObj             = await _testRepository.GetTestByIdAsync(testInstructionsDetails.Id, testInstructionsDetails.CreatedByUserId);

                var categoryAcList = testByIdObj.CategoryAcList;
                foreach (var category in categoryAcList)
                {
                    if (category.NumberOfSelectedQuestion != 0 && category.IsSelect)
                    {
                        testCategoryANameList.Add(category.CategoryName);
                    }
                }
                var testInstructions = new TestInstructionsAC()
                {
                    Duration               = testInstructionsDetails.Duration,
                    BrowserTolerance       = testInstructionsDetails.BrowserTolerance,
                    CorrectMarks           = testInstructionsDetails.CorrectMarks,
                    IncorrectMarks         = testInstructionsDetails.IncorrectMarks,
                    TotalNumberOfQuestions = totalNumberOfQuestions,
                    CategoryNameList       = testCategoryANameList
                };
                return(testInstructions);
            }
            return(null);
        }
예제 #2
0
        public async Task <IActionResult> GetTestByIdAsync([FromRoute] int id)
        {
            var applicationUser = await _userManager.FindByEmailAsync(User.Identity.Name);

            var testAcObject = await _testRepository.GetTestByIdAsync(id, applicationUser.Id);

            if (testAcObject == null)
            {
                return(NotFound());
            }
            return(Ok(testAcObject));
        }