Exemple #1
0
        private async Task <ActionResult> RedirectToFirstTriageQuestion(JourneyViewModel model)
        {
            var pathwayMetadata = await _restClientBusinessApi.ExecuteAsync <PathwayMetaData>(
                new RestRequest(_configuration.GetBusinessApiPathwayMetadataUrl(model.PathwayNo),
                                Method.GET)).ConfigureAwait(false);

            var digitalTitle = pathwayMetadata.Data.DigitalTitle;

            var searchJourneyViewModel = new SearchJourneyViewModel()
            {
                SessionId          = model.SessionId,
                PathwayNo          = model.PathwayNo.ToUpper(),
                DigitalTitle       = digitalTitle,
                CurrentPostcode    = model.CurrentPostcode,
                UserInfo           = model.UserInfo,
                FilterServices     = model.FilterServices,
                Campaign           = model.Campaign,
                Source             = model.Source,
                ViaGuidedSelection = model.ViaGuidedSelection,
                StartParameter     = model.StartParameter
            };

            return(RedirectToAction("FirstQuestion", "JustToBeSafe", new RouteValueDictionary {
                { "pathwayNumber", searchJourneyViewModel.PathwayNo },
                { "gender", searchJourneyViewModel.UserInfo.Demography.Gender },
                { "age", searchJourneyViewModel.UserInfo.Demography.Age },
                { "args", KeyValueEncryptor.EncryptedKeys(searchJourneyViewModel) }
            }));
        }
Exemple #2
0
        private ActionResult RedirectToExplainer(SearchJourneyViewModel model)
        {
            var searchJourneyViewModel = new SearchJourneyViewModel()
            {
                SessionId           = model.SessionId,
                CurrentPostcode     = model.CurrentPostcode,
                UserInfo            = model.UserInfo,
                FilterServices      = model.FilterServices,
                Campaign            = model.Campaign,
                Source              = model.Source,
                SanitisedSearchTerm = model.SanitisedSearchTerm,
                ViaGuidedSelection  = model.ViaGuidedSelection,
                StartParameter      = model.StartParameter
            };

            return(RedirectToAction("Explainer", new RouteValueDictionary {
                { "gender", model.UserInfo.Demography.Gender },
                { "age", model.UserInfo.Demography.Age },
                { "args", KeyValueEncryptor.EncryptedKeys(searchJourneyViewModel) }
            }));
        }
        public async Task <ActionResult> SearchResults(SearchJourneyViewModel model)
        {
            if (!ModelState.IsValidField("SanitisedSearchTerm"))
            {
                return(View("Search", model));
            }

            var ageGroup = new AgeCategory(model.UserInfo.Demography.Age);

            model.EntrySearchTerm = model.SanitisedSearchTerm;

            _userZoomDataBuilder.SetFieldsForSearchResults(model);

            var requestPath = _configuration.GetBusinessApiPathwaySearchUrl(model.UserInfo.Demography.Gender, ageGroup.Value, true);

            var request = new RestRequest(requestPath, Method.POST);

            request.AddJsonBody(Uri.EscapeDataString(model.SanitisedSearchTerm.Trim()));

            var response = await _restClientBusinessApi.ExecuteTaskAsync <List <SearchResultViewModel> >(request);

            model.Results = response.Data
                            .Take(MAX_SEARCH_RESULTS)
                            .Select(r => Transform(r, model.SanitisedSearchTerm.Trim()));

            if (!model.Results.Any())
            {
                var encryptedTopicsQueryStringValues = KeyValueEncryptor.EncryptedKeys(model);

                return(RedirectToRoute("CatergoriesUrl",
                                       new
                {
                    gender = model.UserInfo.Demography.Gender,
                    age = model.UserInfo.Demography.Age.ToString(),
                    args = encryptedTopicsQueryStringValues
                }));
            }

            return(View(model));
        }