Exemplo n.º 1
0
        public string BuildListViewTitleFromFormula(ListView viewSettings, ReadServicesSearchSettingsResponse searchSettings)
        {
            string formula = string.Empty;
            if (Parameters.ContainsKey("Keyword"))
                formula = searchSettings.SearchResultsKeywordTitleFormula;
            else if (Parameters.ContainsKey("PostalCode"))
                formula = searchSettings.SearchResultsZipCodeTitleFormula;
            else
                formula = searchSettings.SearchResultsBaseTitleFormula;

            var title = formula
                .Replace("{" + ServiceSearchResultsToken.KeywordSearched.ToString() + "}", Parameters.ContainsKey("Keyword") ? Parameters["Keyword"] : string.Empty)
                .Replace("{" + ServiceSearchResultsToken.ZipCodeSearched.ToString() + "}", Parameters.ContainsKey("PostalCode") ? Parameters["PostalCode"] : string.Empty)
                .Replace("{" + ServiceSearchResultsToken.PageNum.ToString() + "}", (viewSettings.PageNumber + 1).ToString(CultureInfo.InvariantCulture));

            return ApplyCommonTitleFormatting(title, searchSettings.SeoTitleReplacementValues);
        }
Exemplo n.º 2
0
        public string GetModel(ConvertServiceRequest request)
        {
            _locationContext = ResolveLocationContext(request);

            if (!string.IsNullOrEmpty(request.Data))
                _viewModel = CommonUtils.JsonDeserialize<AdminSettingsViewModel>(request.Data);
            else
                CreateInitialViewModel();

            // Handle special commands
            var command = request.Parameters.ContainsKey("Command") ? request.Parameters["Command"] : null;

            if (command == "InheritSettings")
            {
                InheritSettings(_locationContext.Id, "Services");
                _viewModel.SetSuccessMessage("Settings Successfully Inherited");
            }
            else if (command == "RefreshSiteSearchIndex")
            {
                ProcessOneWayRequest(new UpdateAllServicesG2RecordRequest());
                _viewModel.SetSuccessMessage("The Site Search index is being updated in the background. Changes should become visible within a few minutes.");
                return CommonUtils.JsonSerialize(_viewModel);
            }

            _searchSettings = ProcessRequest<ReadServicesSearchSettingsResponse>(new ReadServicesSearchSettingsRequest() { OrgUnitContextId = _locationContext.Id });

            // Handle settings save request
            if (!string.IsNullOrEmpty(request.Data) && string.IsNullOrEmpty(command))
            {
                Save();
                _viewModel.SetSuccessMessage("Settings Successfully Saved");
            }

            LoadPage(request);

            return CommonUtils.JsonSerialize(_viewModel);
        }