public void SelectLocationShouldCallSessionToSaveProvider()
        {
            //arrange
            //Controller needs a controller context
            var httpContext = new DefaultHttpContext();
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };

            var userVm = new UserSessionVM { ProviderId = "123", LocationId = "234", LocationName = "test location" };           
           
            mockSession.Setup(x => x.SetUserSessionVars(userVm)).Verifiable();
            IOptions<ApplicationSettings> options = Options.Create(appSettings);
           
            mockValidation.Setup(x => x.CleanText(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<List<string>>(), It.IsAny<HashSet<char>>())).Returns("abc");

            //act
            var sut = new SearchController(mockService.Object, mockSession.Object, options, mockValidation.Object);
            sut.ControllerContext = controllerContext;
            sut.SelectLocation(userVm);

            //assert
            mockSession.Verify();
        }
示例#2
0
        public void LocationNotFoundShouldReturn552ErrorCode()
        {
            //arrange
            //Controller needs a controller context
            var httpContext       = new DefaultHttpContext();
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };

            var userVm = new UserSessionVM {
                ProviderId = "123", LocationId = "234", LocationName = "test location"
            };
            var mockSession = new Mock <ISessionService>();
            var mockService = new Mock <ISearchService>();

            mockSession.Setup(x => x.LoadLatestFormIntoSession(It.IsAny <Dictionary <string, string> >())).Throws(new Exception());
            var mockSettings   = new Mock <IOptions <ApplicationSettings> >();
            var mockValidation = new Mock <IGdsValidation>();

            mockValidation.Setup(x => x.CleanText(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <List <string> >(), It.IsAny <HashSet <char> >())).Returns("abc");
            //act
            var sut = new SearchController(mockService.Object, mockSession.Object, mockSettings.Object, mockValidation.Object);

            sut.ControllerContext = controllerContext;
            var response = sut.LocationNotFound();
            //assert
            var result = response as StatusResult;

            result.StatusCode.Should().Be(552);
        }
示例#3
0
        //public bool IsCompleteInfo
        //    => UserSession?.AuthFile?.IsCompleteInfo ?? false;



        public MainWindowVM(ISessionClient d7Client, LogScrollerVM logScroller, UserSessionVM userSessionVM)
            : base(userSessionVM)
        {
            DisplayName = "ErrH Uploader (2nd attempt)";
            OtherTabs.Add(logScroller.ListenTo(this));

            CompletelyLoaded += (src, ea) =>
            {
                UserSession.SetClient(d7Client);

                var foldrsTab = ForwardLogs(IoC.Resolve <FoldersTabVM>());

                foldrsTab.MainList.ItemPicked += (s, e) =>
                { ShowSingleton <FilesTabVM2>(e.Value, IoC); };

                NaviTabs.Add(foldrsTab);
                NaviTabs.SelectOne(0);
                foldrsTab.Refresh();

                //OtherTabs.Add(BatRunner());
                //OtherTabs.SelectOne(1);
                //RaisePropertyChanged(nameof(IsCompleteInfo));
                //UserSession.ra
            };
        }
示例#4
0
        public IActionResult SelectLocation(UserSessionVM vm)
        {
            _sessionService.SetLastPage("search/select-location");

            try
            {
                //Store the location we are giving feedback about
                _sessionService.SetUserSessionVars(vm);

                //Set up our replacement text
                var replacements = new Dictionary <string, string>
                {
                    { "!!location_name!!", vm.LocationName }
                };
                try
                {
                    //Load the Form and the search url into Session
                    _sessionService.LoadLatestFormIntoSession(replacements);
                    var searchUrl = Request.Headers["Referer"].ToString();
                    _sessionService.SaveSearchUrl(searchUrl);

                    var startPage = _config.Value.FormStartPage;
                    return(RedirectToAction("Index", "Form", new { id = startPage, searchReferrer = "select-location" }));
                }
                catch (Exception ex)
                {
                    return(GetCustomErrorCode(EnumStatusCode.SearchSelectLocationJsonError, "Error selecting location. json form not loaded"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("GFCError", "Unexpected error selecting location: '" + vm.LocationName + "'");
                throw ex;
            }
        }
        /// <summary>
        /// 获取用户拥有生产线
        /// </summary>
        /// <param name="userSession"></param>
        /// <param name="useCache"></param>
        /// <param name="cacheSecond"></param>
        /// <returns></returns>
        public List <Base_ProductLine> GetUserProductLine(UserSessionVM userSession, bool useCache = false, int cacheSecond = 3600)
        {
            var ids = userSession.UserRelation.Where(m => m.ObjectType == UserRelationType.ProductLine.ToString()).Select(m => m.ObjectID).ToList();

            var query = Db.Queryable <Base_ProductLine>().WithCacheIF(useCache, cacheSecond).ToList();

            return(query.Where(m => ids.Contains(m.ID)).ToList());
        }
示例#6
0
        public UserSessionVM GetUserSessionVars()
        {
            var returnVm = new UserSessionVM
            {
                SubmissionVm         = GetObject <SubmissionVM>(KeySubmissionVm),
                HasUserComeFromCheck = GetBoolValueFromSession(KeyHasUserComeFromCheck)
            };

            return(returnVm);
        }
示例#7
0
        public void SetUserSessionVars(UserSessionVM vm)
        {
            var context = _httpContextAccessor.HttpContext;

            if (vm.SubmissionVm != null)
            {
                context.Session.SetString(KeySubmissionVm, JsonConvert.SerializeObject(vm.SubmissionVm));
                context.Session.SetString(KeyHasUserComeFromCheck, vm.HasUserComeFromCheck.ToString());
            }
        }
 public void SelectLocationShouldReturnInternalError()
 {
     //arrange
     var userVm = new UserSessionVM { ProviderId = "123", LocationId = "234", LocationName = "test location" };
            
     mockSession.Setup(x => x.SetUserSessionVars(userVm)).Throws(new Exception());
   
     mockValidation.Setup(x => x.CleanText(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<List<string>>(), It.IsAny<HashSet<char>>())).Returns("abc");
     //act
     var sut = new SearchController(mockService.Object, mockSession.Object, mockSettings.Object, mockValidation.Object);
     Action act = () => sut.SelectLocation(userVm);
     //assert
     act.Should().Throw<Exception>().Where(ex => ex.Data.Contains("GFCError"));
 }
示例#9
0
        public void SetUserSessionVars(UserSessionVM vm)
        {
            var context = _httpContextAccessor.HttpContext;

            context.Session.SetString("ProviderId", vm.ProviderId ?? "");
            context.Session.SetString("LocationId", vm.LocationId ?? "");
            context.Session.SetString("LocationName", vm.LocationName ?? "");

            if (vm.NavOrder != null)
            {
                var pageList = string.Join(",", vm.NavOrder.ToArray <string>());
                context.Session.SetString("NavOrder", pageList ?? "");
            }
        }
示例#10
0
        public void TestSaveSubmissionIntoSession()
        {
            var userSessionVm  = new UserSessionVM();
            var mockRepo       = new Mock <IGenericRepository <Submission> >();
            var mockSchemaRepo = new Mock <IGenericRepository <Schema> >();
            var mockSession    = new Mock <ISessionService>();

            mockSession.Setup(x => x.GetUserSessionVars()).Returns(userSessionVm).Verifiable();
            var sut = new SubmissionService(mockRepo.Object, mockSchemaRepo.Object, mockSession.Object);
            //act
            var submissionVm = GetTestSubmissionVm();

            sut.SaveSubmissionIntoSession(submissionVm);
            //assert
            mockSession.Verify();
        }
示例#11
0
        public static TSource ToCreate <TSource>(this TSource source, UserSessionVM userSession)
        {
            if (userSession == null)
            {
                throw new Exception("登录信息已失效,请重新登录");
            }
            var types = source.GetType();

            if (types.GetProperty("ID") != null)
            {
                if (types.GetProperty("ID").GetValue(source) == null || types.GetProperty("ID").GetValue(source).ToString() == "")
                {
                    types.GetProperty("ID").SetValue(source, Guid.NewGuid().ToString().ToUpper(), null);
                }
            }

            if (types.GetProperty("CreateTime") != null)
            {
                types.GetProperty("CreateTime").SetValue(source, DateTime.Now, null);
            }

            if (types.GetProperty("UpdateTime") != null)
            {
                types.GetProperty("UpdateTime").SetValue(source, DateTime.Now, null);
            }

            if (types.GetProperty("CreateID") != null)
            {
                types.GetProperty("CreateID").SetValue(source, userSession.UserID, null);

                types.GetProperty("CreateName").SetValue(source, userSession.UserName, null);
            }

            if (types.GetProperty("UpdateID") != null)
            {
                types.GetProperty("UpdateID").SetValue(source, userSession.UserID, null);

                types.GetProperty("UpdateName").SetValue(source, userSession.UserName, null);
            }

            if (types.GetProperty("deleted") != null)
            {
                types.GetProperty("deleted").SetValue(source, false, null);
            }

            return(source);
        }
示例#12
0
        public UserSessionVM GetUserSession()
        {
            var context       = _httpContextAccessor.HttpContext;
            var userSessionVm = new UserSessionVM
            {
                ProviderId   = context.Session.GetString("ProviderId"),
                LocationId   = context.Session.GetString("LocationId"),
                LocationName = context.Session.GetString("LocationName")
            };

            if (!string.IsNullOrEmpty(context.Session.GetString("NavOrder")))
            {
                userSessionVm.NavOrder = context.Session.GetString("NavOrder").Split(',').ToList();
            }

            return(userSessionVm);
        }
示例#13
0
        public void TestGetSubmissionFromSession()
        {
            var userSessionVm = new UserSessionVM {
                HasUserComeFromCheck = true, SubmissionVm = GetTestSubmissionVm()
            };
            var mockRepo       = new Mock <IGenericRepository <Submission> >();
            var mockSchemaRepo = new Mock <IGenericRepository <Schema> >();
            var mockSession    = new Mock <ISessionService>();

            mockSession.Setup(x => x.GetUserSessionVars()).Returns(userSessionVm).Verifiable();
            var sut = new SubmissionService(mockRepo.Object, mockSchemaRepo.Object, mockSession.Object);
            //act
            var result = sut.GetSubmissionFromSession();

            //assert
            result.Should().NotBeNull();
            mockRepo.Verify();
        }
示例#14
0
        public void TestSaveUserAnswerIntoSession()
        {
            var userSessionVm = new UserSessionVM {
                HasUserComeFromCheck = true, SubmissionVm = GetTestSubmissionVm()
            };
            var mockRepo       = new Mock <IGenericRepository <Submission> >();
            var mockSchemaRepo = new Mock <IGenericRepository <Schema> >();
            var mockSession    = new Mock <ISessionService>();

            mockSession.Setup(x => x.GetUserSessionVars()).Returns(userSessionVm).Verifiable();
            mockSession.Setup(x => x.SetUserSessionVars(It.IsAny <UserSessionVM>())).Verifiable();
            var sut = new SubmissionService(mockRepo.Object, mockSchemaRepo.Object, mockSession.Object);

            //act
            sut.SaveUserAnswerIntoSession(new Question {
                Answer = "yes", DataType = "string", InputType = "text", Options = "", QuestionId = "001", QuestionText = "blah", Validation = null
            });
            //assert
            mockSession.VerifyAll();
        }
示例#15
0
        public void TestGetUserAnswerFromSession()
        {
            var userSessionVm = new UserSessionVM {
                HasUserComeFromCheck = true, SubmissionVm = GetTestSubmissionVm()
            };
            var mockRepo       = new Mock <IGenericRepository <Submission> >();
            var mockSchemaRepo = new Mock <IGenericRepository <Schema> >();
            var mockSession    = new Mock <ISessionService>();

            mockSession.Setup(x => x.GetUserSessionVars()).Returns(userSessionVm).Verifiable();
            var sut = new SubmissionService(mockRepo.Object, mockSchemaRepo.Object, mockSession.Object);
            //act
            var expected = userSessionVm.SubmissionVm.Answers.Where(v => v.QuestionId == "001").FirstOrDefault()
                           .AnswerText;
            var result = sut.GetUserAnswerFromSession("001");

            //assert
            result.Should().BeEquivalentTo(expected);
            mockSession.Verify();
        }
        public static TSource ToUpdate <TSource>(this TSource source, UserSessionVM userSession)
        {
            var types = source.GetType();

            if (types.GetProperty("UpdateTime") != null)
            {
                types.GetProperty("UpdateTime").SetValue(source, DateTime.Now, null);
            }

            if (types.GetProperty("UpdateID") != null)
            {
                types.GetProperty("UpdateID").SetValue(source, userSession.UserID, null);
            }

            if (types.GetProperty("UpdateName") != null)
            {
                types.GetProperty("UpdateName").SetValue(source, userSession.UserName, null);
            }

            return(source);
        }
        public void SearchShouldReturn550StatusCode()
        {
            //arrange
            //Controller needs a controller context
            var httpContext = new DefaultHttpContext();
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };

            var userVm = new UserSessionVM { ProviderId = "123", LocationId = "234", LocationName = "test location" };
                      
            mockService.Setup(x => x.GetPaginatedResult(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), true)).Throws(new Exception());
           
            mockValidation.Setup(x => x.CleanText(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<List<string>>(), It.IsAny<HashSet<char>>())).Returns("abc");
            //act
            var sut = new SearchController(mockService.Object, mockSession.Object, mockSettings.Object, mockValidation.Object);
            sut.ControllerContext = controllerContext;
            var response = sut.SearchResults("searchString", null);
            //assert
            var result = response as StatusResult;
            result.StatusCode.Should().Be(550);
        }
示例#18
0
        public IActionResult SelectLocation(UserSessionVM vm)
        {
            //get the previous location name to replace
            var previousLocation = _sessionService.GetUserSession().LocationName;
            //get the next page from the start page answer
            var formVm      = _sessionService.GetFormVmFromSession();
            var startPageId = _config.Value.FormStartPage;
            var startPage   = formVm.Pages.FirstOrDefault(p => p.PageId == startPageId);

            _sessionService.SetLastPage("search/select-location");

            try
            {
                //Lets clean our vm just in case anyone has tried to inject anything
                vm.LocationName = _gdsValidate.CleanText(vm.LocationName, true);
                vm.LocationId   = _gdsValidate.CleanText(vm.LocationId, true);
                vm.ProviderId   = _gdsValidate.CleanText(vm.ProviderId, true);


                //Store the location we are giving feedback about
                _sessionService.SetUserSessionVars(vm);
                //put the location into the answer
                var searchPage = formVm.Pages.FirstOrDefault(p => p.PageId == "search");
                if (searchPage != null)
                {
                    searchPage.Questions.FirstOrDefault().Answer = vm.LocationName;
                }

                //Set up our replacement text
                var replacements = new Dictionary <string, string>
                {
                    { previousLocation, vm.LocationName }
                };
                try
                {
                    _sessionService.SaveFormVmToSession(formVm, replacements);

                    //Save location data to form
                    _sessionService.UpdateFormData(new List <DataItemVM>()
                    {
                        new DataItemVM()
                        {
                            Id = "LocationName", Value = vm.LocationName
                        },
                        new DataItemVM()
                        {
                            Id = "LocationId", Value = vm.LocationId
                        },
                        new DataItemVM()
                        {
                            Id = "LocationCategory", Value = vm.LocationCategory
                        }
                    });

                    var searchUrl = Request.Headers["Referer"].ToString();
                    _sessionService.SaveSearchUrl(searchUrl);

                    var nextId = _pageHelper.GetNextPageIdFromPage(formVm, startPage.PageId);

                    //set up variables for skipping the where question and navigation to check-your-answers
                    var showExactlyWhere        = _config.Value.SiteTextStrings.CategoriesForExactlyWhereQuestion;
                    var goodBadFeedbackQuestion = _config.Value.QuestionStrings.GoodBadFeedbackQuestion.id;
                    var goodExperienceAnswer    = _config.Value.QuestionStrings.GoodBadFeedbackQuestion.GoodFeedbackAnswer;
                    var whereItHappened         = _config.Value.PageIdStrings?.WhereItHappenedPage;
                    var whenItHappened          = _config.Value.PageIdStrings?.WhenItHappenedPage;


                    var goodJourney = formVm.GetQuestion(goodBadFeedbackQuestion).Answer == goodExperienceAnswer;

                    var skipWhere = (!string.IsNullOrEmpty(vm.LocationCategory) &&
                                     !showExactlyWhere.Any(category => vm.LocationCategory.Contains(category)));

                    //If skipWhere is true, set a flag that will ensure that attempts to load exactly-where will instead load exactly-when
                    _sessionService.UpdateFormData(new List <DataItemVM>()
                    {
                        new DataItemVM()
                        {
                            Id = "skippedExactLocationFlag", Value = skipWhere.ToString()
                        }
                    });

                    //remove any previously entered location not found
                    _sessionService.RemoveFromNavOrder(_config.Value.ServiceNotFoundPage);

                    //If user came from check-your-answers
                    if ((_sessionService.GetChangeMode() ?? "") == _config.Value.SiteTextStrings.ReviewPageId)
                    {
                        //We want to send the user back to CYA unless: they previously skipped the 'where' question and now need to answer it
                        var returnToCya = true;
                        if (skipWhere || goodJourney)
                        {
                            //User should still skip where, so make sure where question is removed from the nav order
                            _sessionService.RemoveFromNavOrder(whereItHappened);
                        }
                        else
                        {
                            //User should have visited the 'where' question => Check if it's been visited/answered before returning to CYA
                            var wherePage = formVm.Pages.FirstOrDefault(p => p.PageId == whereItHappened);

                            //If user has answered 'where', ensure that it's in the nav order
                            if (wherePage != null && wherePage.Questions.All(x => !string.IsNullOrWhiteSpace(x.Answer)))
                            {
                                _sessionService.UpdateNavOrder(whereItHappened);
                            }

                            var wherePageInNavOrder = _sessionService.GetNavOrder().Contains(whereItHappened);
                            if (!wherePageInNavOrder)
                            {
                                //This journey doesn't include 'where' but does require it, so update the redirectId to trigger on 'when' and skip the return to CYA for now
                                returnToCya = false;
                                _sessionService.SaveChangeModeRedirectId(whenItHappened);
                            }
                        }

                        if (returnToCya)
                        {
                            _sessionService.ClearChangeMode();
                            return(RedirectToAction("Index", "CheckYourAnswers"));
                        }
                    }

                    _sessionService.UpdateNavOrder("search");

                    return(RedirectToAction("Index", "Form", new { id = nextId, searchReferrer = "select-location" }));
                }
                catch (Exception ex)
                {
                    return(GetCustomErrorCode(EnumStatusCode.SearchSelectLocationJsonError, "Error selecting location. json form not loaded"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("GFCError", "Unexpected error selecting location: '" + vm.LocationName + "'");
                throw ex;
            }
        }
示例#19
0
        /// <summary>
        /// 创建 Session
        /// </summary>
        public string CreateSession(Sys_Users userInfo, SourceType source, int hours)
        {
            var userSession = Guid.NewGuid().ToString().ToUpper();

            //判断用户是否只允许等于一次
            if (userInfo.OneSession)
            {
                RemoveAllSession(userInfo.UserID);
            }

            var expireTime = DateTime.Now.AddHours(hours);
            var timeSpan   = new TimeSpan(hours, 0, 0);

            //将 Session 添加用户 Session 列表
            RedisServer.Session.HSet(userInfo.UserID, userSession, expireTime);
            RedisServer.Session.Expire(userInfo.UserID, timeSpan);

            //设置 Session 信息
            var userSessionVM = new UserSessionVM()
            {
                UserID       = userInfo.UserID,
                UserName     = userInfo.UserName,
                NickName     = userInfo.NickName,
                Email        = userInfo.Email,
                Sex          = userInfo.Sex,
                AvatarUrl    = userInfo.AvatarUrl,
                QQ           = userInfo.QQ,
                Phone        = userInfo.Phone,
                ProvinceID   = userInfo.ProvinceID,
                Province     = userInfo.Province,
                CityID       = userInfo.CityID,
                City         = userInfo.City,
                CountyID     = userInfo.CountyID,
                County       = userInfo.County,
                Address      = userInfo.Address,
                Remark       = userInfo.Remark,
                IdentityCard = userInfo.IdentityCard,
                Birthday     = userInfo.Birthday,
                CreateTime   = userInfo.CreateTime,
                Enabled      = userInfo.Enabled,
                OneSession   = userInfo.OneSession,
                Source       = source.ToString(),
                KeepHours    = hours,
                UserPower    = _usersService.GetUserPowers(userInfo.UserID),
                UserRelation = _usersService.GetUserRelation(userInfo.UserID),
            };

            RedisServer.Session.HSet(userSession, "UserInfo", userSessionVM);
            RedisServer.Session.Expire(userSession, timeSpan);

            //添加在线记录表
            _onlineService.Add(new Sys_Online()
            {
                SessionID  = userSession,
                UserID     = userInfo.UserID,
                Source     = source.ToString(),
                IPAddress  = _accessor.HttpContext.Connection.RemoteIpAddress?.MapToIPv4().ToString(),
                LoginTime  = DateTime.Now,
                UpdateTime = DateTime.Now
            });

            return(userSession);
        }
示例#20
0
        /// <summary>
        /// 刷新用户所有Session信息
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public void RefreshSession(string userId)
        {
            if (!RedisServer.Session.Exists(userId))
            {
                return;
            }

            //取出 Session 列表所有 Key
            var keys = RedisServer.Session.HKeys(userId);

            if (keys.Length <= 0)
            {
                return;
            }

            var userInfo = _usersService.GetId(userId);

            foreach (var key in keys)
            {
                if (RedisServer.Session.Exists(key))
                {
                    //根据 Session 取出 UserInfo
                    var redisUserInfo = GetSessionItem <UserSessionVM>(key, "UserInfo");

                    //设置 Session 信息
                    var userSessionVM = new UserSessionVM()
                    {
                        UserID       = userInfo.UserID,
                        UserName     = userInfo.UserName,
                        NickName     = userInfo.NickName,
                        Email        = userInfo.Email,
                        Sex          = userInfo.Sex,
                        AvatarUrl    = userInfo.AvatarUrl,
                        QQ           = userInfo.QQ,
                        Phone        = userInfo.Phone,
                        ProvinceID   = userInfo.ProvinceID,
                        Province     = userInfo.Province,
                        CityID       = userInfo.CityID,
                        City         = userInfo.City,
                        CountyID     = userInfo.CountyID,
                        County       = userInfo.County,
                        Address      = userInfo.Address,
                        Remark       = userInfo.Remark,
                        IdentityCard = userInfo.IdentityCard,
                        Birthday     = userInfo.Birthday,
                        CreateTime   = userInfo.CreateTime,
                        Enabled      = userInfo.Enabled,
                        OneSession   = userInfo.OneSession,
                        Source       = redisUserInfo.Source,
                        KeepHours    = redisUserInfo.KeepHours,
                        UserPower    = _usersService.GetUserPowers(userInfo.UserID),
                        UserRelation = _usersService.GetUserRelation(userInfo.UserID),
                    };

                    RedisServer.Session.HSet(key, "UserInfo", userSessionVM);
                }
                else
                {
                    RedisServer.Session.HDel(userId, key);
                }
            }
        }
示例#21
0
        public IActionResult StartQuestions(UserSessionVM vm)
        {
            //Make Sure we have a clean session
            _sessionService.ClearSession();

            _sessionService.SetLastPage("home/start-questions");

            try
            {
                var isFromCqc = false;
                if (string.IsNullOrWhiteSpace(vm.LocationName))
                {
                    vm.LocationName = _config.Value.SiteTextStrings.NonSelectedServiceName;
                }
                else
                {
                    //this location has been set at the CQC site
                    isFromCqc = true;
                }

                //Store the location we are giving feedback about
                _sessionService.SetUserSessionVars(vm);

                //Set up our replacement text
                var replacements = new Dictionary <string, string>
                {
                    { "!!location_name!!", vm.LocationName }
                };
                try
                {
                    //Load the Form and the search url into Session
                    var formVm = _sessionService.LoadLatestFormIntoSession(replacements);
                    //setup the definitive page order
                    var pageOrder = formVm.Pages.OrderBy(x => x.DisplayOrder).Select(p => p.PageId).ToList();
                    _sessionService.PageOrder = string.Join(",", pageOrder);
                    if (isFromCqc)
                    {
                        //make sure the search page can be accessed from check your answers
                        var searchPage = formVm.Pages.FirstOrDefault(p => p.PageId == "search");
                        if (searchPage != null)
                        {
                            searchPage.Questions.FirstOrDefault().Answer = vm.LocationName;
                        }
                        _sessionService.SaveFormVmToSession(formVm);

                        //Add a flag to the form, and save location data
                        _sessionService.UpdateFormData(new List <DataItemVM>()
                        {
                            new DataItemVM()
                            {
                                Id = "LocationFromCqcFlag", Value = "true"
                            },
                            new DataItemVM()
                            {
                                Id = "skippedExactLocationFlag", Value = "False"
                            },                                                                   //This capitalisation is deliberate, to aid boolean conversion
                            new DataItemVM()
                            {
                                Id = "LocationName", Value = vm.LocationName
                            },
                            new DataItemVM()
                            {
                                Id = "LocationId", Value = vm.LocationId
                            },
                            new DataItemVM()
                            {
                                Id = "LocationCategory", Value = "unknown"
                            }
                        });
                    }
                    var startPage = _config.Value.FormStartPage;
                    return(RedirectToAction("Index", "Form", new { id = startPage, searchReferrer = "start-questions" }));
                }
                catch (Exception ex)
                {
                    return(GetCustomErrorCode(EnumStatusCode.SearchSelectLocationJsonError, "Error selecting location. json form not loaded"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("GFCError", "Unexpected error start questions: " + vm.LocationName);
                throw ex;
            }
        }