예제 #1
0
        public SearchResult <RoleGroupDTO> GetDataByFilter(RoleGroupSearchFilter filter)
        {
            if (string.IsNullOrEmpty(filter.SortName))
            {
                filter.SortName = "RoleGroup_PK";
            }
            RoleGroupQuery roleGroupQuery = new RoleGroupQuery(this.Db);

            var filteredRecords =
                roleGroupQuery.GetQuery()
                .Where(roleGroup =>
                       roleGroup.Title.Contains(filter.Keyword)
                       ||
                       roleGroup.Description.Contains(filter.Keyword));

            var displayedRecords = filteredRecords.
                                   SortBy(filter.SortName, filter.SortDir)
                                   .Skip(filter.Skip)
                                   .Take(filter.PageSize)
                                   .ToList();

            var searchResult = new SearchResult <RoleGroupDTO>(filter);

            searchResult.Filter               = filter;
            searchResult.Count.TotalRecords   = roleGroupQuery.GetTotalRecords();
            searchResult.Count.TotalFiltered  = filteredRecords.Count();
            searchResult.Count.TotalDisplayed = displayedRecords.Count();
            searchResult.Records              = displayedRecords;

            return(searchResult);
        }
예제 #2
0
        public RoleGroupListModel Get(RoleGroupSearchFilter searchFilter)
        {
            RoleGroupListFormData       formData     = new RoleGroupListFormData();
            SearchResult <RoleGroupDTO> searchResult = roleGroupSearch.GetDataByFilter(searchFilter);

            return(new RoleGroupListModel()
            {
                FormData = formData,
                SearchResult = searchResult
            });
        }
예제 #3
0
        public IHttpActionResult Search([FromUri] RoleGroupSearchFilter filter)
        {
            ThrowIfUserHasNoRole(readRole);
            if (filter == null)
            {
                throw new KairosException("Missing search filter parameter");
            }

            using (var roleGroupSearch = new RoleGroupSearch(Db))
            {
                var data = roleGroupSearch.GetDataByFilter(filter);
                return(Ok(new SuccessResponse(data)));
            }
        }
예제 #4
0
        public IHttpActionResult Search([FromUri] RoleGroupSearchFilter filter)
        {
            string accessType = "RoleGroup_ViewAll";

            ThrowIfUserCannotAccess(accessType);
            if (filter == null)
            {
                throw new KairosException("Missing search filter parameter");
            }

            using (var roleGroupSearch = new RoleGroupSearch(Db))
            {
                var data = roleGroupSearch.GetDataByFilter(filter);
                return(Ok(new SuccessResponse(data)));
            }
        }