Selaa lähdekoodia

Added cast for double fields.

Kenric Nugteren 2 kuukautta sitten
vanhempi
commit
4038c6ebbd

+ 12 - 0
InABox.Core/DigitalForms/Layouts/Fields/DFLayoutDoubleField/DFLayoutDoubleFieldProperties.cs

@@ -1,4 +1,5 @@
 using Newtonsoft.Json.Linq;
+using System;
 
 namespace InABox.Core
 {
@@ -39,6 +40,17 @@ namespace InABox.Core
             var value = entry.GetValue();
             if (value is double d)
                 return d;
+            if (value != null && value.GetType().IsNumeric())
+            {
+                try
+                {
+                    return Convert.ToDouble(value);
+                }
+                catch (Exception)
+                {
+                    return null;
+                }
+            }
             if (double.TryParse(value as string, out var result))
                 return result;
             return null;