public IQueryable <Shipment> GetShipments(ShipmentsPagingParameters pagingParameters)
 {
     return(_context.Shipments
            .Where(o => o.Id.ToString().Contains(pagingParameters.Id ?? "") &&
                   o.CustomerId.ToString().Contains(pagingParameters.CustomerId ?? "") &&
                   o.OrderId.ToString().Contains(pagingParameters.OrderId ?? "") &&
                   o.Status.Contains(pagingParameters.Status ?? ""))
            .Skip(pagingParameters.PageSize * (pagingParameters.PageNumber - 1))
            .Take(pagingParameters.PageSize));
 }
 public IActionResult GetShipments(ShipmentsPagingParameters shipmentsParams)
 {
     try
     {
         var shipmentsFromRepo       = _repo.GetShipments(shipmentsParams).ToList();
         var shipments               = Mapper.Map <IEnumerable <ShipmentDto> >(shipmentsFromRepo);
         ShipmentsPagedResult result = new ShipmentsPagedResult {
             TotalResultCount = _repo.GetShipmentsCount(),
             data             = shipments.ToList()
         };
         return(Ok(result));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public async Task <IActionResult> GetShipments(ShipmentsPagingParameters shipmentParams)
        {
            var uri = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(_client.BaseAddress.ToString(),
                                                                                    ObjectToDictionaryConverter.ConvertToDictionary(shipmentParams));

            var shipmentResponse = await _client.GetAsync(uri);

            if (shipmentResponse.IsSuccessStatusCode)
            {
                var shipmentsStream = await shipmentResponse.Content.ReadAsStreamAsync();

                var shipments = Serializer.Deserialize <ShipmentsPagedResult>(shipmentsStream);
                if (shipments != null)
                {
                    return(StatusCode((int)shipmentResponse.StatusCode, shipments));
                }
            }
            return(StatusCode((int)shipmentResponse.StatusCode));
        }