public async Task <HttpResponseMessage> GetOutletByName(string outletName, int?pageSize, int?pageNumber) { var message = CreateMessageData($"name/{outletName}", new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("outletName", outletName), new KeyValuePair <string, string>("pageSize", pageSize.ToString()), new KeyValuePair <string, string>("pageNumber", pageNumber.ToString()) }); var outletList = await _outletService.GetOutletByNameCA(outletName); if (!outletList.IsSuccess) { return(CreateValidationErrorResponse(message, new ValidationResult(outletList.message))); } if (outletList.Result == null) { return(CreateNotFoundResponse(message, Validation.FileNotFound)); } var numOfRecords = outletList.Result.Count(); if (pageSize.HasValue && pageNumber.HasValue) { if (numOfRecords <= ((pageSize - 1) * (pageNumber - 1))) { return(CreateBadRequestErrorResponse(message, Validation.InvalidPageIndex)); } var result = outletList.Result.Skip((pageNumber.Value - 1) * pageSize.Value).Take(pageSize.Value); return(CreateOkResponse(message, result, pageNumber, pageSize, outletList.Result.Count())); } return(CreateOkResponse(message, outletList.Result)); }