private static SearchEventsUniqueTitleRequest CreateRequest()
 {
     var request = new SearchEventsUniqueTitleRequest();
     return request;
 }
 private SearchEventsUniqueTitleResponse DoSearch(SearchEventsUniqueTitleRequest request)
 {
     var handler = CreateHandler();
     return HandleRequest<SearchEventsUniqueTitleResponse>(handler, request);
 }
Ejemplo n.º 3
0
        private string LoadDropdownValues(ModuleInstanceView parent, SearchView viewSettings, IDictionary<string, string> parameters)
        {
            List<DropdownOption> records = new List<DropdownOption>();

            // Get location context settings
            var locationId = LocationContextHelper.ResolveLocationContext(parent, viewSettings, parameters).Id;
            var descendantOption = LocationContextHelper.ResolveLocationDescendantOption(viewSettings, parameters);

            switch (parameters["FieldName"])
            {
                case "Event":
                    var eventTitleRequest = new SearchEventsUniqueTitleRequest() { Title = parameters["Search"], OrganizationalUnitId = locationId, DescendantOption = descendantOption };
                    var eventTitleResponse = parent.ProcessRequest<SearchEventsUniqueTitleResponse>(eventTitleRequest);
                    foreach (var eventTitle in eventTitleResponse.Results)
                    {
                        records.Add(new DropdownOption
                        {
                            DisplayName = eventTitle,
                            Id = eventTitle
                        });
                    }
                    break;
                case "Location":
                    var locationRequest = new SearchEventLocationsRequest() { OrganizationalUnitName = parameters["Search"], OrganizationalUnitId = locationId, DescendantOption = descendantOption };
                    var locationResponse = parent.ProcessRequest<SearchEventLocationsResponse>(locationRequest);
                    foreach (var location in locationResponse.OrgUnitInfo)
                    {
                        records.Add(new DropdownOption
                        {
                            DisplayName = location.Value,
                            Id = location.Key
                        });
                    }
                    break;
                case "EventType":
                    var eventTypeRequest = new ListFilteredEventTypesRequest() { EnabledOnly = true, OrganizationalUnitId = locationId, DescendantOption = descendantOption };
                    var eventTypeResponse = parent.ProcessRequest<ListFilteredEventTypesResponse>(eventTypeRequest);
                    foreach (var type in eventTypeResponse.EventTypes.Where(t => t.Name.ToLowerInvariant().StartsWith(parameters["Search"].ToLowerInvariant())))
                    {
                        records.Add(new DropdownOption
                        {
                            DisplayName = type.Name,
                            Id = type.Id
                        });
                    }
                    break;
                case "EventTopic":
                    var eventTopicsRequest = new ListFilteredEventTopicsRequest() { EnabledOnly = true, OrganizationalUnitId = locationId, DescendantOption = descendantOption };
                    var eventTopicsResponse = parent.ProcessRequest<ListFilteredEventTopicsResponse>(eventTopicsRequest);
                    foreach (var topic in eventTopicsResponse.EventTopics.Where(t => t.Name.ToLowerInvariant().StartsWith(parameters["Search"].ToLowerInvariant())))
                    {
                        records.Add(new DropdownOption
                        {
                            DisplayName = topic.Name,
                            Id = topic.Id
                        });
                    }
                    break;
            }

            return CommonUtils.JsonSerialize(records);
        }