public static async Task <PaginatedResponseDTO <T> > GetHelper <T>(this IHttpService httpService, string url,
                                                                           PaginationDTO paginationDTO)
        {
            string newURL = "";

            if (url.Contains("?"))
            {
                newURL = $"{url}&page={paginationDTO.Page}&recordsPerPage={paginationDTO.ItemPerPage}";
            }
            else
            {
                newURL = $"{url}?page={paginationDTO.Page}&recordsPerPage={paginationDTO.ItemPerPage}";
            }

            var httpResponse = await httpService.Get <T>(newURL);

            var totalAmountPages  = int.Parse(httpResponse.HttpResponseMessage.Headers.GetValues("totalAmountPages").FirstOrDefault());
            var paginatedResponse = new PaginatedResponseDTO <T>
            {
                Response         = httpResponse.Response,
                TotalAmountPages = totalAmountPages
            };

            return(paginatedResponse);
        }
Exemple #2
0
        public async Task <PaginatedResponseDTO <List <Room> > > GetItemsFiltered(FilterItemDTO filterItem)
        {
            var responseHTTP = await _httpService.Post <FilterItemDTO, List <Room> >($"{url}/filter", filterItem);

            var totalAmountPages = int.Parse(responseHTTP.HttpResponseMessage.Headers.GetValues("totalAmountPages").FirstOrDefault());

            var paginatedResponse = new PaginatedResponseDTO <List <Room> >()
            {
                Response         = responseHTTP.Response,
                TotalAmountPages = totalAmountPages
            };

            return(paginatedResponse);
        }