public IHttpActionResult GetAllNameId(string currentPage, string pageSize) { //if user is not admin return.. var identity = User.Identity as ClaimsIdentity; string userRole = identity.FindFirst(ClaimTypes.Role).Value; string clientId = identity.FindFirst("ClientId").Value; if (userRole != "admin") { return(BadRequest("UnauthorizedAccess")); } AppClient appClient = new AppClient(); int totalCount = 0; var result = AppClient.GetAll(int.Parse(currentPage), pageSize == "0" ? 999 : int.Parse(pageSize), out totalCount) .Select(i => new { i.Id, i.Name }); return(Ok(new { records = result, totalCount = totalCount, defaultClient = clientId })); }