private List <ISpeciesObservationFieldDescription> GetAllTableFields()
        {
            SpeciesObservationFieldDescriptionList fields;
            var fieldList = new List <ISpeciesObservationFieldDescription>();

            fields = SpeciesObservationFieldDescriptionViewManager.GetAllFieldsExceptProjectParameters(userContext);
            foreach (ISpeciesObservationFieldDescription field in fields)
            {
                // class name fields are just headers
                if (field.IsClass)
                {
                    continue;
                }

                fieldList.Add(field);
            }

            fieldList = fieldList.OrderBy(x => x.SortOrder).ToList();
            return(fieldList);
        }
示例#2
0
        /// <summary>
        /// Gets all table field ids that is lower or equal to importance.
        /// </summary>
        /// <param name="userContext">The user context.</param>
        /// <param name="importance">The importance.</param>
        public List <ISpeciesObservationFieldDescription> GetTableFieldsByImportance(IUserContext userContext, int importance)
        {
            var fieldList = new List <ISpeciesObservationFieldDescription>();
            SpeciesObservationFieldDescriptionList fields;

            fields = SpeciesObservationFieldDescriptionViewManager.GetAllFieldsExceptProjectParameters(userContext);
            foreach (ISpeciesObservationFieldDescription field in fields)
            {
                // class name fields are just headers
                if (field.IsClass)
                {
                    continue;
                }

                if (field.Importance <= importance)
                {
                    fieldList.Add(field);
                }
            }
            fieldList = fieldList.OrderBy(x => x.SortOrder).ToList();
            return(fieldList);
        }
        /// <summary>
        /// Get list of field descriptions to be displayed in drop down list in web page.
        /// </summary>
        /// <param name="className">Name of class to filter the list.</param>
        /// <returns>List of field list item view models.</returns>
        public List <FieldListItemViewModel> GetFieldsViewModelByClassName(String className)
        {
            SpeciesObservationFieldDescriptionList fieldDescriptions;

            fieldDescriptions = SpeciesObservationFieldDescriptionViewManager.GetAllFieldsExceptProjectParameters(UserContext);
            List <FieldListItemViewModel> fieldViewList = new List <FieldListItemViewModel>();
            FieldListItemViewModel        fieldView;

            var fields = fieldDescriptions.Where(f => f.IsSearchable);

            foreach (var field in fields)
            {
                // If class name is empty then get all fields
                if (String.IsNullOrWhiteSpace(className) || (field.Class.GetName().Equals(className) && !field.IsClass))
                {
                    fieldView = new FieldListItemViewModel {
                        Id = field.Id, Name = field.Name
                    };
                    fieldViewList.Add(fieldView);
                }
            }

            return(fieldViewList);
        }