diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config index e86b823..a33c2a7 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config @@ -2,6 +2,7 @@ + diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/UsersController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/UsersController.cs index 9987377..0a65dee 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/UsersController.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/UsersController.cs @@ -1,4 +1,5 @@ using System; +using System.Configuration; using System.Net; using System.Net.Http; using System.Net.Http.Headers; @@ -29,8 +30,9 @@ namespace WindowsDataCenter public IHttpActionResult GetUsers([FromUri] string query = "",[FromUri] int pageSize = -1, [FromUri] int pageNumber =-1) { _logger.Trace("GetUsers called with arguments >> query: {0}, pageSize: {1}, pageNumber: {2}", query, pageSize, pageNumber); + pageNumber = pageNumber == -1 ? 1 : pageNumber; - pageSize = pageSize == -1 ? 1 : pageSize; + pageSize = GetPageSize(pageSize); var userList = query == string.Empty ? _repo.GetUsers(pageNumber, pageSize) : _repo.Search(query); _logger.Trace("Got UserList from Repository, UserCount: {0}", userList.UserCount); if (query != string.Empty) @@ -50,6 +52,15 @@ namespace WindowsDataCenter return ResponseMessage(msg); } + private int GetPageSize(int pageSize) + { + var cfgPageSize = ConfigurationManager.AppSettings["DefaultPageSize"] ?? 10.ToString(); + + return pageSize == -1 + ? Convert.ToInt32(cfgPageSize) + : pageSize; + } + [HttpGet] [Route("{id:int}")] [CacheControl(MaxAge = 0)] diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj index b9c024b..012fb8d 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj @@ -110,6 +110,7 @@ + ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net451\System.Data.SQLite.dll diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config index 9f000de..8c1062c 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config @@ -2,6 +2,7 @@ +