public async Task<HttpResponseMessage> GetDeviceRulesAsDataTablesResponseAsync()
        {
            return await GetServiceResponseAsync<DataTablesResponse<DeviceRule>>(async () =>
            {
                var queryResult = await _deviceRulesLogic.GetAllRulesAsync();

                var dataTablesResponse = new DataTablesResponse<DeviceRule>()
                {
                    RecordsTotal = queryResult.Count,
                    RecordsFiltered = queryResult.Count,
                    Data = queryResult.ToArray()
                };

                return dataTablesResponse;

            }, false);
        }
        public async Task<HttpResponseMessage> GetDeviceActionsAsDataTablesResponseAsync()
        {
            return await GetServiceResponseAsync<DataTablesResponse<ActionMappingExtended>>(async () =>
            {
                List<ActionMappingExtended> queryResult = await _actionMappingLogic.GetAllMappingsAsync();

                var dataTablesResponse = new DataTablesResponse<ActionMappingExtended>()
                {
                    RecordsTotal = queryResult.Count,
                    RecordsFiltered = queryResult.Count,
                    Data = queryResult.ToArray()
                };

                return dataTablesResponse;

            }, false);
        }
        public async Task<HttpResponseMessage> GetDevices([FromBody]JObject requestData)
        {
            var dataTableRequest = requestData.ToObject<DataTablesRequest>();
            var sortColumnIndex = dataTableRequest.SortColumns[0].ColumnIndex;

            var listQuery = new DeviceListQuery()
            {
                SortOrder = dataTableRequest.SortColumns[0].SortOrder,
                SortColumn = dataTableRequest.Columns[sortColumnIndex].Name,
                
                SearchQuery = dataTableRequest.Search.Value,

                Filters = dataTableRequest.Filters,

                Skip = dataTableRequest.Start,
                Take = dataTableRequest.Length
            };

            return await GetServiceResponseAsync<DataTablesResponse>(async () =>
            {
                var queryResult = await _deviceLogic.GetDevices(listQuery);

                var dataTablesResponse = new DataTablesResponse()
                {
                    Draw = dataTableRequest.Draw,
                    RecordsTotal = queryResult.TotalDeviceCount,
                    RecordsFiltered = queryResult.TotalFilteredCount,
                    Data = queryResult.Results.ToArray()
                };

                return dataTablesResponse;

            }, false);
        }