Exemplo n.º 1
0
        public IHttpActionResult GetLocationsByCriteria([FromBody] LocDataFilter criteria)
        {
            sortingPagingInfo.SortField        = criteria.order;
            sortingPagingInfo.SortDirection    = criteria.orderDir;
            sortingPagingInfo.PageSize         = criteria.size;
            sortingPagingInfo.CurrentPageIndex = criteria.page;

            var source      = locRepository.GetLocationsWithPaging(criteria.keyword, criteria.PipelineDuns, criteria.PopupFor, criteria.IsSpecialDelCase, sortingPagingInfo);
            int count       = sortingPagingInfo.PageCount;
            int CurrentPage = sortingPagingInfo.CurrentPageIndex;
            int PageSize    = sortingPagingInfo.PageSize;
            int TotalCount  = count;

            int TotalPages = (int)Math.Ceiling(count / (double)PageSize);

            // if CurrentPage is greater than 1 means it has previousPage
            var previousPage = CurrentPage > 1 ? "Yes" : "No";

            // if TotalPages is greater than CurrentPage means it has nextPage
            var nextPage = CurrentPage < TotalPages ? "Yes" : "No";

            // Object which we are going to send in header
            var paginationMetadata = new
            {
                totalCount  = TotalCount,
                pageSize    = PageSize,
                currentPage = CurrentPage,
                totalPages  = TotalPages,
                previousPage,
                nextPage
            };

            // Setting Header
            HttpContext.Current.Response.Headers.Add("Paging-Headers", JsonConvert.SerializeObject(paginationMetadata));

            if (source == null)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Location is not found.")));
            }
            return(Ok(source));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetLocationByIdentifier([FromBody] LocDataFilter criteria)
        {
            var result = locRepository.GetLocationByIdentifier(criteria.Identifier, criteria.PipelineDuns);

            return(Ok(result));
        }
Exemplo n.º 3
0
        public IHttpActionResult GetTotalLocationCount([FromBody] LocDataFilter criteria)
        {
            int LocationCount = locRepository.GetTotalLocationCount(criteria.keyword, criteria.PipelineDuns, criteria.PopupFor, criteria.IsSpecialDelCase);

            return(Ok(LocationCount));
        }