public async Task <IActionResult> GetTestByLinkAsync([FromRoute] string link, [FromRoute] bool isPreview) { var attendeeId = 0; if (link == null) { return(BadRequest()); } if (!await _testConductRepository.IsTestInValidDateWindow(link, isPreview)) { return(NotFound()); } if (isPreview == false) { await HttpContext.Session.LoadAsync(); attendeeId = HttpContext.Session.GetInt32(_stringConstants.AttendeeIdSessionKey).Value; if (!await IsAttendeeValid(attendeeId)) { return(NotFound()); } } var testDetails = await _testRepository.GetTestByLinkAsync(link); if (isPreview == false) { await _testRepository.SetStartTestLogAsync(attendeeId); } return(Ok(testDetails)); }