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)); }
public async Task GetTestAttendeeByIdAsyncTest() { var testAttendee = InitializeTestAttendeeParameters(); await CreateTestAsync(); await _testConductRepository.RegisterTestAttendeesAsync(testAttendee); var attendeeId = await _trappistDbContext.TestAttendees.OrderBy(x => x.Email).Where(x => x.Email.Equals(testAttendee.Email)).Select(x => x.Id).FirstOrDefaultAsync(); var attendee = await _testConductRepository.GetTestAttendeeByIdAsync(attendeeId); Assert.NotNull(attendee); }