Sfoglia il codice sorgente

Converted "No Date Provided" to "Null" to allow more different data types

Kenric Nugteren 1 anno fa
parent
commit
352a79e126
2 ha cambiato i file con 28 aggiunte e 20 eliminazioni
  1. 23 18
      InABox.Core/CoreUtils.cs
  2. 5 2
      InABox.Core/Filter.cs

+ 23 - 18
InABox.Core/CoreUtils.cs

@@ -589,25 +589,30 @@ namespace InABox.Core
             if (value is string && type == typeof(byte[]))
                 return Convert.FromBase64String(value as string);
 
-            if (value is FilterConstant && type == typeof(DateTime))
+            if(value is FilterConstant constant)
             {
-                if (Equals(FilterConstant.NoDateProvided, value))
-                    return DateTime.MinValue;
-                return value;
-            }
-            
-            if (value is FilterConstant && type == typeof(double))
-            {
-                return value;
-                //    if (Equals(FilterConstant.Zero, value))
-                //        return (double)0;
-            }
-            
-            if (value is FilterConstant && type == typeof(int))
-            {
-                return value;
-                //    if (Equals(FilterConstant.Zero, value))
-                //        return 0;
+                if (type == typeof(DateTime))
+                {
+                    if (Equals(FilterConstant.Null, value))
+                        return DateTime.MinValue;
+                    return value;
+                }
+                if (type == typeof(Guid) && constant == FilterConstant.Null)
+                {
+                    return Guid.Empty;
+                }
+                if (type == typeof(double))
+                {
+                    return value;
+                    //    if (Equals(FilterConstant.Zero, value))
+                    //        return (double)0;
+                }
+                if (type == typeof(int))
+                {
+                    return value;
+                    //    if (Equals(FilterConstant.Zero, value))
+                    //        return 0;
+                }
             }
 
             if (type == typeof(String))

+ 5 - 2
InABox.Core/Filter.cs

@@ -129,7 +129,7 @@ namespace InABox.Core
         EndOfThisFinancialYear,
         StartOfNextFinancialYear,
         EndOfNextFinancialYear,
-        NoDateProvided
+        Null
     }
 
     public static class FilterConstants
@@ -146,10 +146,13 @@ namespace InABox.Core
         
         public static FilterConstant[] Constants(Type type, Operator op)
         {
+            if (type == typeof(Guid) && op == Operator.IsEqualTo || op == Operator.IsNotEqualTo)
+                return new[] { FilterConstant.Null };
+
             if ((type == typeof(DateTime)) && SimpleOperators.Contains(op))
                 return new[]
                 {
-                    FilterConstant.NoDateProvided,
+                    FilterConstant.Null,
                     FilterConstant.Today, 
                     FilterConstant.Now,       
                     FilterConstant.OneWeekAgo,