Esempio n. 1
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;

            switch (command)
            {
                case "InheritSettings":
                    InheritSettings(_locationContext.Id, "Organizational Units");
                    InheritSettings(_locationContext.Id, "Lead Management");
                    _viewModel.SetSuccessMessage("Settings Successfully Inherited");
                    break;
                case "ChangeCmsType":
                    var existingGroup = _viewModel.SettingGroups.Single(g => g.Name == _cmsIntegrationSettingsGroupName);
                    var updatedGroup = BuildCmsIntegrationSettings(CommonUtils.GetFieldValue(existingGroup.Fields, "CmsType"));
                    existingGroup.Fields = updatedGroup.Fields;
                    return CommonUtils.JsonSerialize(_viewModel);
                case "RefreshSiteSearchIndex":
                    ProcessOneWayRequest(new UpdateAllLocationsG2RecordRequest());
                    _viewModel.SetSuccessMessage("The Site Search index is being updated in the background. Changes should become visible within a few minutes.");
                    return CommonUtils.JsonSerialize(_viewModel);
            }

            // Load latest settings
            _searchSettings = ProcessRequest<ReadOrgUnitSearchSettingsResponse>(new ReadOrgUnitSearchSettingsRequest() { 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);
        }
Esempio 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, "Providers");
                _viewModel.SetSuccessMessage("Settings Successfully Inherited");
            }
            else if (command == "RefreshSiteSearchIndex")
            {
                ProcessOneWayRequest(new UpdateAllProvidersG2RecordRequest());
                _viewModel.SetSuccessMessage("The Site Search index is being updated in the background. Changes should become visible within a few minutes.");
                return CommonUtils.JsonSerialize(_viewModel);
            }

            // Load latest settings
            _searchSettings = ProcessRequest<ReadSearchSettingsResponse>(new ReadSearchSettingsRequest() { OrgUnitContextId = _locationContext.Id }).Settings;

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

            LoadPage(request);

            return CommonUtils.JsonSerialize(_viewModel);
        }
        public IEnumerable<SettingLocation> BuildSettingLocations(AdminSettingsViewModel viewModel, int? locationId, string groupName)
        {
            var request = new ListOrgUnitAssociationsRequest() { SecondaryIsSite = true, IsEnabled = true, PageSize = -1, SortField = "SecondaryPath", SortDirection = "Ascending" };
            var response = ProcessRequest<ListOrgUnitAssociationsResponse>(request);

            var locations = new List<SettingLocation>();

            locations.Add(new SettingLocation() { Id = 0, Name = "- Global Defaults -" });

            foreach (var association in response.OrgUnitAssociations)
            {
                locations.Add(new SettingLocation() { Id = association.SecondaryId.Value, Name = association.SecondaryPath });
            }

            if (locationId.HasValue)
            {
                viewModel.SelectedLocation = locations.SingleOrDefault(l => l.Id == locationId);
                viewModel.SelectedLocation.HasUniqueSettings = HasUniqueSettings(locationId, groupName);
            }
            else
                viewModel.SelectedLocation = locations[0];

            return locations;
        }
Esempio n. 4
0
        private void CreateInitialViewModel()
        {
            //Build View Model
            _viewModel = new AdminSettingsViewModel()
            {
                ModuleName = "location",
                EntityName = "settings",
                PageHeader = "Location Settings"
            };

            _viewModel.NavLinks = LocationUtils.CreateLocationNavLinks().ToList();
            _viewModel.SubEntityNavLinks = LocationUtils.CreateLocationSubEntityNavLinks().ToList();
        }
Esempio n. 5
0
        private void CreateInitialViewModel()
        {
            //Build View Model
            _viewModel = new AdminSettingsViewModel()
            {
                ModuleName = "service",
                EntityName = "settings",
                PageHeader = "Services Settings"
            };

            _viewModel.NavLinks = ServicesUtils.CreateServicesNavLinks().ToList();
            _viewModel.SubEntityNavLinks = ServicesUtils.CreateServicesSubEntityNavLinks().ToList();
        }
Esempio n. 6
0
        private void CreateInitialViewModel()
        {
            //Build View Model
            _viewModel = new AdminSettingsViewModel()
            {
                ModuleName = "provider",
                EntityName = "settings",
                PageHeader = "Provider Settings"
            };

            _viewModel.NavLinks = ProviderUtils.CreateProviderNavLinks().ToList();
            _viewModel.SubEntityNavLinks = ProviderUtils.CreateProviderSubEntityNavLinks().ToList();
        }
Esempio n. 7
0
        private void CreateInitialViewModel()
        {
            //Build View Model
            _viewModel = new AdminSettingsViewModel()
            {
                ModuleName = "event",
                EntityName = "settings",
                PageHeader = "Event Settings"
            };

            _viewModel.NavLinks = EventUtils.CreateEventNavLinks().ToList();
            _viewModel.SubEntityNavLinks = EventUtils.CreateEventSubEntityNavLinks().ToList();
        }