public List <ApiKey> GetApiKeys()
        {
            List <ApiKey> ret = new List <ApiKey>();

            DataTable result = _Database.Select(API_KEY_TABLE, null, null, null, null, null);

            if (result != null && result.Rows.Count > 0)
            {
                foreach (DataRow row in result.Rows)
                {
                    ret.Add(ApiKey.FromDataRow(row));
                }
            }

            return(ret);
        }
        public ApiKey GetApiKeyByGuid(string guid)
        {
            if (String.IsNullOrEmpty(guid))
            {
                throw new ArgumentNullException(nameof(guid));
            }

            Expression e      = new Expression("GUID", Operators.Equals, guid);
            DataTable  result = _Database.Select(API_KEY_TABLE, null, null, null, e, null);

            if (result != null && result.Rows.Count > 0)
            {
                return(ApiKey.FromDataRow(result.Rows[0]));
            }

            return(null);
        }
Example #3
0
 private T DataTableToObject <T>(DataTable result) where T : class
 {
     if (result == null || result.Rows.Count < 1)
     {
         return(null);
     }
     if (typeof(T) == typeof(ApiKey))
     {
         return(ApiKey.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(UserMaster))
     {
         return(UserMaster.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(Permission))
     {
         return(Permission.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(UrlLock))
     {
         return(UrlLock.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(Container))
     {
         return(Container.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(ObjectMetadata))
     {
         return(ObjectMetadata.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(ContainerKeyValuePair))
     {
         return(ContainerKeyValuePair.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(ObjectKeyValuePair))
     {
         return(ObjectKeyValuePair.FromDataRow(result.Rows[0]) as T);
     }
     else if (typeof(T) == typeof(AuditLogEntry))
     {
         return(AuditLogEntry.FromDataRow(result.Rows[0]) as T);
     }
     throw new ArgumentException("Unknown object type: " + typeof(T).Name);
 }