// GET api/setting
 public dynamic GetGridData([FromUri] JqGridSearchModel searchModel)
 {
     var data = GetQuery(_service.Query(),searchModel);
     var dataList = data.Items.Select(x => new { x.Id, x.Name, x.Value }).ToList();
     var grid = new JqGridModel
     {
         total = data.TotalPage,
         page = data.CurrentPage,
         records = data.TotalNumber,
         rows = dataList.Select(x => new { id = x.Id, cell = new object[] { x.Id, x.Name, x.Value } }).ToArray()
     };
     return grid;
 }
        // GET api/quartztask
        public dynamic GetGridData([FromUri] JqGridSearchModel searchModel)
        {
            int totalRecords;
            var dataList = GetQuery(searchModel, out totalRecords);
            var totalPages = (int)Math.Ceiling((float)totalRecords / searchModel.rows);

            var grid = new JqGridModel
            {
                total = totalPages,
                page = searchModel.page,
                records = totalRecords,
                rows = dataList.Select(x => new
                {
                    id = x.TriggerGroup + "," + x.TriggerName,
                    cell = new object[] { x.TriggerGroup + "," + x.TriggerName, x.TriggerGroup, x.TriggerName, x.JobGroup, x.JobName, x.Description, x.CronExpression, x.TimeZone, x.State, x.PreviousTimeUtc, x.StartTimeUtc, x.EndTimeUtc, x.Parameters }
                }).ToArray()
            };

            return grid;
        }
 // GET api/task
 public dynamic GetGridData([FromUri] JqGridSearchModel searchModel)
 {
     var data = GetQuery(_service.Query(),searchModel);
     var dataList = data.Items.ToList();
     var grid = new JqGridModel
     {
         total = data.TotalPage,
         page = data.CurrentPage,
         records = data.TotalNumber,
         rows = dataList.Select(x => new { id = x.Id, cell = new object[] { x.Id, x.Name, x.Seconds, x.Type, x.Enabled, x.StopOnError, x.LastStartUtc, x.LastEndUtc, x.LastSuccessUtc } }).ToArray()
     };
     return grid;
 }
 public dynamic GetUserRoles(Guid id, [FromUri] JqGridSearchModel searchModel)
 {
     if (id == default(Guid))
         return BadRequest("User id cannot be empty.");
     if (!HasPermission(id, Constants.ROLE_ADMIN))
         return Unauthorized();
     var data = GetUserRolesQuery(id,searchModel);
     var dataList = data.Items.Select(x => new
     {
         x.Id,
         x.Name,
         x.Description,
         x.HasRole
     }).ToList();
     var grid = new JqGridModel
     {
         total = data.TotalPage,
         page = data.CurrentPage,
         records = data.TotalNumber,
         rows = dataList.Select(x => new
         {
             id = x.Id,
             cell = new object[] {
                 x.Id,
                 x.Name,
                 x.Description,
                 x.HasRole}
         }).ToArray()
     };
     return grid;
 }
 // GET api/role
 public dynamic GetGridData([FromUri] JqGridSearchModel searchModel)
 {
     var data = GetQuery(_userService.Query(),searchModel);
     var dataList = data.Items.Select(x => new
     {
         x.ID,
         x.Tenant,
         x.Username,
         x.Email,
         x.FirstName,
         x.LastName,
         x.LastUpdated,
         x.Created,
         x.LastLogin,
         x.IsAccountClosed,
         x.AccountClosed,
         x.IsLoginAllowed,
         x.LastFailedLogin,
         x.FailedLoginCount,
         x.PasswordChanged,
         x.RequiresPasswordReset,
         x.IsAccountVerified,
         x.LastFailedPasswordReset,
         x.FailedPasswordResetCount,
         //x.MobileCode,
         //x.MobileCodeSent,
         x.MobilePhoneNumber,
         //x.MobilePhoneNumberChanged,
         //x.AccountTwoFactorAuthMode,
         //x.CurrentTwoFactorAuthStatus,
         x.VerificationKey,
         x.VerificationKeySent,
         x.VerificationPurpose/*,
         x.VerificationStorage,
         x.HashedPassword*/
     }).ToList();
     var grid = new JqGridModel
     {
         total = data.TotalPage,
         page = data.CurrentPage,
         records = data.TotalNumber,
         rows = dataList.Select(x => new
         {
             id = x.ID,
             cell = new object[] {
                 x.ID,
                 x.Tenant,
                 x.Username,
                 x.Email,
                 x.FirstName,
                 x.LastName,
                 x.LastUpdated,
                 x.Created,
                 x.LastLogin,
                 x.IsAccountClosed,
                 x.AccountClosed,
                 x.IsLoginAllowed,
                 x.LastFailedLogin,
                 x.FailedLoginCount,
                 x.PasswordChanged,
                 x.RequiresPasswordReset,
                 x.IsAccountVerified,
                 x.LastFailedPasswordReset,
                 x.FailedPasswordResetCount,
                 //x.MobileCode,
                 //x.MobileCodeSent,
                 x.MobilePhoneNumber,
                 //x.MobilePhoneNumberChanged,
                 //x.AccountTwoFactorAuthMode,
                 //x.CurrentTwoFactorAuthStatus,
                 x.VerificationKey,
                 x.VerificationKeySent,
                 x.VerificationPurpose/*,
                 x.VerificationStorage,
                 x.HashedPassword*/ }
         }).ToArray()
     };
     return grid;
 }
 public dynamic GetRolePermissions(Guid id, [FromUri] JqGridSearchModel searchModel)
 {
     if (id == default(Guid))
         return BadRequest("Role id cannot be empty.");
     var data = GetRolePermissionsQuery(id, searchModel);
     var grid = new JqGridModel
     {
         total = data.TotalPage,
         page = data.CurrentPage,
         records = data.TotalNumber,
         rows = data.Items.ToList().Select(x => new
         {
             id = x.Id,
             cell = new object[] {
                 x.Id,
                 x.Name,
                 x.Description,
                 x.HasPermission}
         }).ToArray()
     };
     return grid;
 }
 public dynamic GetGridData([FromUri] JqGridSearchModel searchModel)
 {
     var data = GetQuery(_service.Query(),searchModel);
     var dataList = data.Items.ToList();
     var grid = new JqGridModel
     {
         total = data.TotalPage,
         page = data.CurrentPage,
         records = data.TotalNumber,
         rows = dataList.Select(x => new { id = x.Id, cell = new object[] { x.Id, x.Application, x.CreatedDate, x.Activity, x.Detail, x.UserName, x.ClientIP } }).ToArray()
     };
     return grid;
 }