Kaynağa Gözat

Fix to Data entry panel not attaching PO documents

Kenric Nugteren 1 yıl önce
ebeveyn
işleme
0135e82297
1 değiştirilmiş dosya ile 16 ekleme ve 15 silme
  1. 16 15
      prs.desktop/Panels/DataEntry/DataEntryPanel.xaml.cs

+ 16 - 15
prs.desktop/Panels/DataEntry/DataEntryPanel.xaml.cs

@@ -346,23 +346,24 @@ public partial class DataEntryPanel : UserControl, IBasePanel, IDynamicEditorHos
 
     private void SaveDocument(DataEntryDocument dataEntryDocument)
     {
-        var linktype = CoreUtils.TypeList(x =>
-            x.GetInterfaces().Contains(typeof(IEntityLink))
-            && x.BaseType != null
-            && x.BaseType.IsGenericType
-            && x.BaseType.GenericTypeArguments.FirstOrDefault() == _selectedType
-        ).FirstOrDefault();
-        if (linktype == null)
-            return;
-        
         var doctype = CoreUtils.TypeList(x =>
-            x.GetInterfaces().Contains(typeof(IEntityDocument))
-            && x.BaseType != null
-            && x.BaseType.IsGenericType
-            && x.BaseType.GenericTypeArguments.FirstOrDefault() == linktype
-        ).FirstOrDefault();
-        if (doctype == null)
+        {
+            var entityDoc = x.GetInterfaceDefinition(typeof(IEntityDocument<>));
+            if (entityDoc is null)
+            {
+                return false;
+            }
+            var linkType = entityDoc.GenericTypeArguments[0].GetInterfaceDefinition(typeof(IEntityLink<>));
+            if (linkType is null)
+            {
+                return false;
+            }
+            return linkType.GenericTypeArguments[0] == _selectedType;
+        }).FirstOrDefault();
+        if(doctype is null)
+        {
             return;
+        }
 
         var doc = (IEntityDocument)Activator.CreateInstance(doctype)!;
         CoreUtils.SetPropertyValue(doc,"EntityLink.ID",_entityID);