Example #1
0
        /// <summary>
        /// Get entity collection
        /// freeTextSearch - looks for in any text field
        /// </summary>
        public UserListData GetList(string filter)
        {
            using (var scope = Scope("GetList"))
            {
                // authorize
                AuthProvider.Authorize(Permission.User_Management);

                // process
                var maxRows = AppConfig.WebApplication.GridMaxRows;
                var list    = UserManager.GetList(filter, null, maxRows + 1).ToArray();
                Helper.ValidateResult(list);

                return(scope.Complete(
                           () => new UserListData()
                {
                    List = list.Take(maxRows).Select(t => new User(t)).ToArray(),
                    TooMuchData = list.Count() > maxRows
                },
                           t => $"User list loaded {t.List.Length} items."
                           ));
            }
        }
Example #2
0
        /// <summary>
        /// Get entity collection
        /// freeTextSearch - looks for in any text field
        /// </summary>
        public AutoCompleteListData GetList(AutoCompleteType type, string filter)
        {
            using (var scope = Scope("GetList"))
            {
                switch (type)
                {
                case AutoCompleteType.User:
                {
                    // authorize
                    AuthProvider.Authorize(Permission.AutoComplete_GetUsers);

                    // process
                    var maxRows = AppConfig.WebApplication.AutoCompleteMaxRows;
                    var list    = UserManager.GetList(null, filter, maxRows + 1).ToArray();
                    Helper.ValidateResult(list);

                    return(scope.Complete(
                               () => new AutoCompleteListData()
                        {
                            List = list.Take(maxRows).Select(t => new AutoCompleteItem(t.UserId, t.FullName)).OrderBy(t => t.Value).ToArray(),
                            TooMuchData = list.Count() > maxRows
                        },
                               t => $"AutoComplete User list loaded {t.List.Length} items."
                               ));
                }

                default:
                    return(scope.Complete(
                               () => new AutoCompleteListData()
                    {
                        List = new AutoCompleteItem[] { }
                    },
                               t => $"Invalid AutoComplete type, returning empty list: {type}."
                               ));
                }
            }
        }