private ListRefinerView BuildAdminSettingsView(ModuleInstanceView parent, ListRefinerView settingsData)
        {
            settingsData.AvailableFields.Clear();

            settingsData.AvailableFields.Add(new Field("Event Topics", "Event Topics", FieldTypes.Filter, null) { FilterSettings = CreateTestFilterSettings("EventTopicId") });

            //Org Unit Types
            var orgUnitTypes = parent.ProcessRequest<ListOrgUnitTypesResponse>(new ListOrgUnitTypesRequest() { IsEnabled = true, ExcludeOutsideOrgUnit = true }).OrgUnitTypes;
            foreach (var type in orgUnitTypes.Where(t => t.Name != Constants.Locations.LocationTypePrintableProviderDirectory))
            {
                settingsData.AvailableFields.Add(new Field(type.Name, type.Name, FieldTypes.Filter, null) { FilterSettings = CreateTestFilterSettings("LocationId") });
            }

            //Dynamic Columns
            var dynamicColumns = CommonUtils.GetDynamicColumnInstances(parent, Constants.EventDynamicColumnEntityId);
            foreach (var col in dynamicColumns.Where(c => c.DataType != "contentEditor" && c.DataType != "datetime"))
            {
                settingsData.AvailableFields.Add(new Field(Constants.DynamicColumnPrefix + col.FormLabel, col.FormLabel, FieldTypes.Filter, null) { FilterSettings = CreateTestFilterSettings(Constants.DynamicColumnPrefix + col.Name) });
            }

            settingsData.AvailableFields = settingsData.AvailableFields.OrderBy(f => f.DisplayName).ToList();

            // Add admin-only settings
            LocationContextHelper.AddLocationSettingsGroup(parent, settingsData);

            return settingsData;
        }
        private ListRefinerView BuildPublicSettingsView(ModuleInstanceView parent, ListRefinerView settingsData, IDictionary<string, string> parameters)
        {
            // Establish correct search results page URL
            settingsData.UpdateSettingValue("SearchResultsPageUrl", EventUtils.CalculateSearchResultsUrl(settingsData, parent.SearchSettings.SearchResultsPageUrl));

            var searchRequest = BuildRequest(parent, settingsData, parameters);
            var searchResponse = parent.ProcessRequest<ListSearchFiltersResponse>(searchRequest);

            PopulateSearchFilterValues(searchResponse.FilterTypes, settingsData, parameters);

            return settingsData;
        }
        private ListSearchFiltersRequest BuildRequest(ModuleInstanceView parent, ListRefinerView settingsData, IDictionary<string, string> parameters)
        {
            var searchRequest = new ListSearchFiltersRequest();

            // Location Context
            searchRequest.OrganizationalUnitId = LocationContextHelper.ResolveLocationContext(parent, settingsData, parameters).Id;
            searchRequest.DescendantOption = LocationContextHelper.ResolveLocationDescendantOption(settingsData, parameters);
            //Keyword
            if (parameters.ContainsKey("Keyword"))
                searchRequest.Keyword = parameters["Keyword"];
            //Event Title
            if (parameters.ContainsKey("EventId"))
                searchRequest.Title = parameters["EventId"];
            if (parameters.ContainsKey("EventText"))
                searchRequest.Title = parameters["EventText"];
            //Location
            if (parameters.ContainsKey("LocationId"))
                searchRequest.OrganizationalUnitId = int.Parse(parameters["LocationId"]);
            if (parameters.ContainsKey("LocationText"))
                searchRequest.OrganizationalUnitName = parameters["LocationText"];
            //Event Topic
            if (parameters.ContainsKey("EventTopicId"))
                searchRequest.EventTopicId = int.Parse(parameters["EventTopicId"]);
            //Event Type
            if (parameters.ContainsKey("EventTypeId"))
                searchRequest.EventTypeId = int.Parse(parameters["EventTypeId"]);
            //Start Date
            if (parameters.ContainsKey("StartDate"))
                searchRequest.EventStartDate = DateTime.Parse(parameters["StartDate"]);
            //End Date
            if (parameters.ContainsKey("EndDate"))
                searchRequest.EventEndDate = DateTime.Parse(parameters["EndDate"]);
            //Postal Code
            if (parameters.ContainsKey("PostalCode"))
                searchRequest.PostalCode = parameters["PostalCode"];
            //Search Radius
            if (parameters.ContainsKey("RadiusDistance") && !string.IsNullOrEmpty(parameters["RadiusDistance"]))
                searchRequest.SearchRadius = int.Parse(parameters["RadiusDistance"]);

            //Dynamic Column Filtering
            if (parameters.Any(p => p.Key.StartsWith(Constants.DynamicColumnPrefix)))
            {
                var dynamicFilters = new List<string>();
                foreach (var item in parameters.Where(p => p.Key.StartsWith(Constants.DynamicColumnPrefix)))
                {
                    dynamicFilters.Add(item.Value);
                }
                searchRequest.DynamicColumns = dynamicFilters;
            }

            return searchRequest;
        }
        public string GetModelData(ModuleInstanceView parent, string settingsData, IDictionary<string, string> parameters, bool isConfigView)
        {
            ListRefinerView viewSettings = null;

            if (string.IsNullOrEmpty(settingsData))
                viewSettings = new ListRefinerView();
            else
                viewSettings = CommonUtils.JsonDeserialize<ListRefinerView>(settingsData);

            if (isConfigView)
                viewSettings = BuildAdminSettingsView(parent, viewSettings);
            else
            {
                viewSettings = BuildPublicSettingsView(parent, viewSettings, parameters);
                viewSettings.AvailableFields.Clear();
            }

            return CommonUtils.JsonSerializeMinimum(viewSettings);
        }
예제 #5
0
        public static string ReadEventOccurrencSummary(ModuleInstanceView parent, IDictionary<string, string> parameters)
        {
            var request = new ReadEventOccurrenceSummaryRequest();
            request.EventOccurrenceId = int.Parse(parameters["EventOccurrenceId"]);
            var occurrence = parent.ProcessRequest<ReadEventOccurrenceSummaryResponse>(request).EventOccurrenceSummary;

            var occurrenceSummary = new EventOccurrenceSummaryModel()
            {
                Id = occurrence.Id,
                EventTitle = occurrence.EventTitle,
                EventImageUrl = occurrence.EventImagePath,
                EventSpecialInstructions = occurrence.EventSpecialInstructions,
                AvailableSeats = occurrence.AvailableSeats,
                Description = occurrence.EventSummaryDescription,
                OccurrenceSpecialInstructions = occurrence.SpecialInstructions,
                IsGuestDemographicInfoRequired = occurrence.IsGuestDemographicInfoRequired,
                LocationName = occurrence.EffectiveLocationName,
                StartDate = occurrence.StartDate.HasValue ? occurrence.StartDate.Value.ToString("M/d/yy h:mm tt") : "Open",
                LeadManagementBusinessUnitId = occurrence.BrightWhistleBusinessUnitId
            };

            return CommonUtils.JsonSerialize(occurrenceSummary);
        }