public async Task <IActionResult> Index(Guid uniqueCode) { var idClaim = HttpContext.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier); //System.Security.Claims.ClaimTypes.NameIdentifier var employerEmailDetail = await _employerEmailDetailsRepository.GetEmployerInviteForUniqueCode(uniqueCode); if (employerEmailDetail == null) { _logger.LogWarning($"Attempt to use invalid unique code: {uniqueCode}"); return(NotFound()); } var providerAttributes = await _employerEmailDetailsRepository.GetAllAttributes(); if (providerAttributes == null) { _logger.LogError($"Unable to load Provider Attributes from the database."); return(RedirectToAction("Error", "Error")); } var providerAttributesModel = providerAttributes.Select(s => new ProviderAttributeModel { Name = s.AttributeName }); var newSurveyModel = MapToNewSurveyModel(employerEmailDetail, providerAttributesModel); newSurveyModel.UniqueCode = uniqueCode; await _sessionService.Set(idClaim.Value, newSurveyModel); var encodedAccountId = _encodingService.Encode(employerEmailDetail.AccountId, EncodingType.AccountId); return(RedirectToRoute(RouteNames.Landing_Get_New, new { encodedAccountId = encodedAccountId })); }
public override void OnActionExecuting(ActionExecutingContext context) { var uniqueCode = (Guid)context.ActionArguments["uniqueCode"]; var isCodeBurnt = _employerEmailDetailRepository.IsCodeBurnt(uniqueCode).Result; if (isCodeBurnt) { var employerEmailDetail = _employerEmailDetailRepository.GetEmployerInviteForUniqueCode(uniqueCode).GetAwaiter().GetResult(); var encodedAccountId = _encodingService.Encode(employerEmailDetail.AccountId, EncodingType.AccountId); var controller = context.Controller as Controller; context.Result = controller.RedirectToRoute(RouteNames.FeedbackAlreadySubmitted, new { encodedAccountId = encodedAccountId }); } }