public ApiResponse <List <KeyValuePair <String, String> > > GetLookup([FromRoute] LookupFactoryType id) => new ApiResponse <List <KeyValuePair <String, String> > >() { Data = (new LookupFactory()).Get(id), Success = true };
/// <summary> /// Get a lookup of a given type /// </summary> /// <param name="type">The lookup type</param> /// <returns>The lookup dictionary</returns> public List <KeyValuePair <String, String> > Get(LookupFactoryType type) { // Result List <KeyValuePair <String, String> > result = new List <KeyValuePair <String, String> >(); // Check the type to get the right lookup type switch (type) { case LookupFactoryType.Culture: // Get the list of cultures available result = CultureInfo.GetCultures(CultureTypes.AllCultures) .Select(culture => new KeyValuePair <String, String>(culture.Name, culture.DisplayName) ).OrderBy(column => column.Value).ToList(); break; case LookupFactoryType.Encoding: // Get the list of encodings result = Encoding.GetEncodings() .Select(encoding => new KeyValuePair <String, String>(encoding.Name, encoding.DisplayName) ).OrderBy(column => column.Value).ToList(); break; case LookupFactoryType.DataTypes: // Get a list of data types with the appropriate title result = dataTypes .Select(dataType => new KeyValuePair <String, String>( dataType.ToString(), dataType.ToShortName().UppercaseFirst() ) ).OrderBy(x => x.Value).ToList(); // Return the data types constant break; case LookupFactoryType.DataPropertyTypes: // Cast the enumeration to a format that can be returned result = EnumToList(typeof(DataItemPropertyType)); break; case LookupFactoryType.DataItemPropertyBagItems: // Cast the enumeration to a format that can be returned result = EnumToList(typeof(PropertyBagItemTypeEnum)); break; case LookupFactoryType.ObjectTypes: // Cast the enumeration to a format that can be returned result = EnumToList(typeof(ObjectTypes)); break; } // Return the result return(result); }