public SearchResult <DeliveryAreaDTO> GetDataByFilter(DeliveryAreaSearchFilter filter)
        {
            if (string.IsNullOrEmpty(filter.SortName))
            {
                filter.SortName = "DeliveryArea_PK";
            }
            DeliveryAreaQuery deliveryAreaQuery = new DeliveryAreaQuery(this.Db);

            var filteredRecords =
                deliveryAreaQuery.GetQuery()
                .Where(deliveryArea =>
                       deliveryArea.Title.Contains(filter.Keyword));

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

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

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

            return(searchResult);
        }
        public DeliveryAreaListModel Get(DeliveryAreaSearchFilter searchFilter)
        {
            DeliveryAreaListFormData       formData     = new DeliveryAreaListFormData();
            SearchResult <DeliveryAreaDTO> searchResult = deliveryAreaSearch.GetDataByFilter(searchFilter);

            return(new DeliveryAreaListModel()
            {
                FormData = formData,
                SearchResult = searchResult
            });
        }
        public IHttpActionResult Search([FromUri] DeliveryAreaSearchFilter filter)
        {
            ThrowIfUserHasNoRole(readRole);
            if (filter == null)
            {
                throw new KairosException("Missing search filter parameter");
            }

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