Esempio n. 1
0
        public SearchResult <PositionDTO> GetDataByFilter(PositionSearchFilter filter)
        {
            if (string.IsNullOrEmpty(filter.SortName))
            {
                filter.SortName = "Position_PK";
            }
            PositionQuery positionQuery = new PositionQuery(this.Db);

            var filteredRecords =
                positionQuery.GetQuery()
                .Where(position =>
                       position.Name.Contains(filter.Keyword)
                       ||
                       position.Description.Contains(filter.Keyword));

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

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

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

            return(searchResult);
        }
        public PositionListModel Get(PositionSearchFilter searchFilter)
        {
            PositionListFormData       formData     = new PositionListFormData();
            SearchResult <PositionDTO> searchResult = positionSearch.GetDataByFilter(searchFilter);

            return(new PositionListModel()
            {
                FormData = formData,
                SearchResult = searchResult
            });
        }
        public IHttpActionResult Search([FromUri] PositionSearchFilter filter)
        {
            string accessType = "Position_ViewAll";

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

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