public IQueryable <Customer> GetCustomers(CustomersPagingParameters pagingParameters) { return(_context.Customers .Where(c => c.Name.Contains(pagingParameters.Name ?? "") && c.Address.Contains(pagingParameters.Address ?? "") && c.Business.Contains(pagingParameters.Business ?? "")) .Skip(pagingParameters.PageSize * (pagingParameters.PageNumber - 1)) .Take(pagingParameters.PageSize)); }
public IActionResult GetCustomers(CustomersPagingParameters customerParams) { try { var customersFromRepo = _repo.GetCustomers(customerParams).ToList(); var customers = Mapper.Map <IEnumerable <CustomerDTO> >(customersFromRepo); //CustomersPagedResult result = new CustomersPagedResult //{ // TotalResultCount = _repo.GetResultCount(), // data = customers.ToList() //}; return(Ok(customers)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <IActionResult> GetCustomers(CustomersPagingParameters customerParams) { var uri = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(_client.BaseAddress.ToString(), ObjectToDictionaryConverter.ConvertToDictionary(customerParams)); var customerResponse = await _client.GetAsync(uri); if (customerResponse.IsSuccessStatusCode) { var customersStream = await customerResponse.Content.ReadAsStreamAsync(); var customers = Serializer.Deserialize <List <CustomerDTO> >(customersStream); if (customers != null) { return(StatusCode((int)customerResponse.StatusCode, customers)); } } return(StatusCode((int)customerResponse.StatusCode)); }