Browse Source

fixed one to many sync

tags/v1.0
Robin Thoni 8 years ago
parent
commit
879b139cf2

+ 86
- 86
backend/WebSem/.idea/.idea.WebSem/.idea/workspace.xml View File

@@ -2,17 +2,13 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="8d054e21-e284-419c-acba-f672639639a4" name="Default" comment="">
5
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/.idea.WebSem/.idea/dataSources.local.xml" afterPath="$PROJECT_DIR$/.idea/.idea.WebSem/.idea/dataSources.local.xml" />
6
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/.idea.WebSem/.idea/dataSources.xml" afterPath="$PROJECT_DIR$/.idea/.idea.WebSem/.idea/dataSources.xml" />
7 5
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/.idea.WebSem/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/.idea.WebSem/.idea/workspace.xml" />
8 6
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/WebApiWebSem/DataAccess/ArticlesDataAccess.cs" afterPath="$PROJECT_DIR$/WebApiWebSem/DataAccess/ArticlesDataAccess.cs" />
9 7
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/WebApiWebSem/DataAccess/ModelsDbo.cs" afterPath="$PROJECT_DIR$/WebApiWebSem/DataAccess/ModelsDbo.cs" />
10
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/app/controllers/articles.controller.js" afterPath="$PROJECT_DIR$/../../frontend/WebSem/app/controllers/articles.controller.js" />
8
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/app/less/app.less" afterPath="$PROJECT_DIR$/../../frontend/WebSem/app/less/app.less" />
11 9
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/app/translations/en.json" afterPath="$PROJECT_DIR$/../../frontend/WebSem/app/translations/en.json" />
12
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/app/views/articles.html" afterPath="$PROJECT_DIR$/../../frontend/WebSem/app/views/articles.html" />
13 10
       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/app/views/articlesedit.html" afterPath="$PROJECT_DIR$/../../frontend/WebSem/app/views/articlesedit.html" />
14
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/sdk/Business/listcontrollerbuilder.business.js" afterPath="$PROJECT_DIR$/../../frontend/WebSem/sdk/Business/listcontrollerbuilder.business.js" />
15
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/sdk/DataAccess/articles.dataaccess.js" afterPath="$PROJECT_DIR$/../../frontend/WebSem/sdk/DataAccess/articles.dataaccess.js" />
11
+      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/../../frontend/WebSem/sdk/Business/apputils.business.js" afterPath="$PROJECT_DIR$/../../frontend/WebSem/sdk/Business/apputils.business.js" />
16 12
     </list>
17 13
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
18 14
     <option name="TRACKING_ENABLED" value="true" />
@@ -48,25 +44,30 @@
48 44
       <file leaf-file-name="ArticlesDataAccess.cs" pinned="false" current-in-tab="true">
49 45
         <entry file="file://$PROJECT_DIR$/WebApiWebSem/DataAccess/ArticlesDataAccess.cs">
50 46
           <provider selected="true" editor-type-id="text-editor">
51
-            <state relative-caret-position="-113">
52
-              <caret line="48" column="69" lean-forward="true" selection-start-line="48" selection-start-column="69" selection-end-line="48" selection-end-column="69" />
47
+            <state relative-caret-position="445">
48
+              <caret line="105" column="43" lean-forward="true" selection-start-line="105" selection-start-column="43" selection-end-line="105" selection-end-column="43" />
53 49
               <folding>
54
-                <marker date="1487541118573" expanded="true" signature="6:273" ph="..." />
55
-                <marker date="1487541118573" expanded="true" signature="308:2856" ph="{...}" />
56
-                <marker date="1487541118573" expanded="true" signature="444:2854" ph="{...}" />
57
-                <marker date="1487541118573" expanded="true" signature="645:665" ph="{...}" />
58
-                <marker date="1487541118573" expanded="true" signature="717:760" ph="{...}" />
59
-                <marker date="1487541118573" expanded="true" signature="869:964" ph="{...}" />
60
-                <marker date="1487541118573" expanded="true" signature="1033:1085" ph="{...}" />
61
-                <marker date="1487541118573" expanded="true" signature="1145:1383" ph="{...}" />
62
-                <marker date="1487541118573" expanded="true" signature="1281:1338" ph="{...}" />
63
-                <marker date="1487541118573" expanded="true" signature="1484:1620" ph="{...}" />
64
-                <marker date="1487541118573" expanded="true" signature="1697:2221" ph="{...}" />
65
-                <marker date="1487541118573" expanded="true" signature="1752:2210" ph="{...}" />
66
-                <marker date="1487541118573" expanded="true" signature="2014:2153" ph="{...}" />
67
-                <marker date="1487541118573" expanded="true" signature="2312:2722" ph="{...}" />
68
-                <marker date="1487541118573" expanded="true" signature="2527:2666" ph="{...}" />
69
-                <marker date="1487541118573" expanded="true" signature="2794:2848" ph="{...}" />
50
+                <marker date="1487546558945" expanded="true" signature="6:307" ph="..." />
51
+                <marker date="1487546558945" expanded="true" signature="342:4021" ph="{...}" />
52
+                <marker date="1487546558945" expanded="true" signature="478:4019" ph="{...}" />
53
+                <marker date="1487546558945" expanded="true" signature="679:699" ph="{...}" />
54
+                <marker date="1487546558945" expanded="true" signature="751:794" ph="{...}" />
55
+                <marker date="1487546558945" expanded="true" signature="903:998" ph="{...}" />
56
+                <marker date="1487546558945" expanded="true" signature="1108:1175" ph="{...}" />
57
+                <marker date="1487546558945" expanded="true" signature="1244:1296" ph="{...}" />
58
+                <marker date="1487546558945" expanded="true" signature="1356:1594" ph="{...}" />
59
+                <marker date="1487546558945" expanded="true" signature="1492:1549" ph="{...}" />
60
+                <marker date="1487546558945" expanded="true" signature="1695:1831" ph="{...}" />
61
+                <marker date="1487546558945" expanded="true" signature="1908:2432" ph="{...}" />
62
+                <marker date="1487546558945" expanded="true" signature="1963:2421" ph="{...}" />
63
+                <marker date="1487546558945" expanded="true" signature="2225:2364" ph="{...}" />
64
+                <marker date="1487546558945" expanded="true" signature="2523:2682" ph="{...}" />
65
+                <marker date="1487546558945" expanded="true" signature="2825:3887" ph="{...}" />
66
+                <marker date="1487546558945" expanded="true" signature="3000:3086" ph="{...}" />
67
+                <marker date="1487546558945" expanded="true" signature="3146:3379" ph="{...}" />
68
+                <marker date="1487546558945" expanded="true" signature="3533:3833" ph="{...}" />
69
+                <marker date="1487546558945" expanded="true" signature="3629:3817" ph="{...}" />
70
+                <marker date="1487546558945" expanded="true" signature="3959:4013" ph="{...}" />
70 71
               </folding>
71 72
             </state>
72 73
           </provider>
@@ -75,19 +76,9 @@
75 76
       <file leaf-file-name="ModelsDbo.cs" pinned="false" current-in-tab="false">
76 77
         <entry file="file://$PROJECT_DIR$/WebApiWebSem/DataAccess/ModelsDbo.cs">
77 78
           <provider selected="true" editor-type-id="text-editor">
78
-            <state relative-caret-position="450">
79
-              <caret line="34" column="30" lean-forward="false" selection-start-line="34" selection-start-column="30" selection-end-line="34" selection-end-column="30" />
80
-              <folding>
81
-                <marker date="1487540897085" expanded="true" signature="6:157" ph="..." />
82
-                <marker date="1487540897085" expanded="true" signature="192:1247" ph="{...}" />
83
-                <marker date="1487540897085" expanded="true" signature="228:1245" ph="{...}" />
84
-                <marker date="1487540897085" expanded="true" signature="308:600" ph="{...}" />
85
-                <marker date="1487540897085" expanded="true" signature="349:406" ph="{...}" />
86
-                <marker date="1487540897085" expanded="true" signature="460:589" ph="{...}" />
87
-                <marker date="1487540897085" expanded="true" signature="662:1239" ph="{...}" />
88
-                <marker date="1487540897085" expanded="true" signature="703:760" ph="{...}" />
89
-                <marker date="1487540897085" expanded="true" signature="808:1228" ph="{...}" />
90
-              </folding>
79
+            <state relative-caret-position="432">
80
+              <caret line="33" column="83" lean-forward="false" selection-start-line="33" selection-start-column="83" selection-end-line="33" selection-end-column="83" />
81
+              <folding />
91 82
             </state>
92 83
           </provider>
93 84
         </entry>
@@ -295,12 +286,12 @@
295 286
       <workItem from="1487108080916" duration="3508000" />
296 287
       <workItem from="1487345029610" duration="5634000" />
297 288
       <workItem from="1487441650798" duration="14018000" />
298
-      <workItem from="1487528667649" duration="8537000" />
289
+      <workItem from="1487528667649" duration="11486000" />
299 290
     </task>
300 291
     <servers />
301 292
   </component>
302 293
   <component name="TimeTrackingManager">
303
-    <option name="totallyTimeSpent" value="35403000" />
294
+    <option name="totallyTimeSpent" value="38352000" />
304 295
   </component>
305 296
   <component name="TodoView">
306 297
     <todo-panel id="selected-file">
@@ -356,22 +347,27 @@
356 347
         <state relative-caret-position="0">
357 348
           <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
358 349
           <folding>
359
-            <marker date="1487541118573" expanded="true" signature="6:273" ph="..." />
360
-            <marker date="1487541118573" expanded="true" signature="308:2856" ph="{...}" />
361
-            <marker date="1487541118573" expanded="true" signature="444:2854" ph="{...}" />
362
-            <marker date="1487541118573" expanded="true" signature="645:665" ph="{...}" />
363
-            <marker date="1487541118573" expanded="true" signature="717:760" ph="{...}" />
364
-            <marker date="1487541118573" expanded="true" signature="869:964" ph="{...}" />
365
-            <marker date="1487541118573" expanded="true" signature="1033:1085" ph="{...}" />
366
-            <marker date="1487541118573" expanded="true" signature="1145:1383" ph="{...}" />
367
-            <marker date="1487541118573" expanded="true" signature="1281:1338" ph="{...}" />
368
-            <marker date="1487541118573" expanded="true" signature="1484:1620" ph="{...}" />
369
-            <marker date="1487541118573" expanded="true" signature="1697:2221" ph="{...}" />
370
-            <marker date="1487541118573" expanded="true" signature="1752:2210" ph="{...}" />
371
-            <marker date="1487541118573" expanded="true" signature="2014:2153" ph="{...}" />
372
-            <marker date="1487541118573" expanded="true" signature="2312:2722" ph="{...}" />
373
-            <marker date="1487541118573" expanded="true" signature="2527:2666" ph="{...}" />
374
-            <marker date="1487541118573" expanded="true" signature="2794:2848" ph="{...}" />
350
+            <marker date="1487546558945" expanded="true" signature="6:307" ph="..." />
351
+            <marker date="1487546558945" expanded="true" signature="342:4021" ph="{...}" />
352
+            <marker date="1487546558945" expanded="true" signature="478:4019" ph="{...}" />
353
+            <marker date="1487546558945" expanded="true" signature="679:699" ph="{...}" />
354
+            <marker date="1487546558945" expanded="true" signature="751:794" ph="{...}" />
355
+            <marker date="1487546558945" expanded="true" signature="903:998" ph="{...}" />
356
+            <marker date="1487546558945" expanded="true" signature="1108:1175" ph="{...}" />
357
+            <marker date="1487546558945" expanded="true" signature="1244:1296" ph="{...}" />
358
+            <marker date="1487546558945" expanded="true" signature="1356:1594" ph="{...}" />
359
+            <marker date="1487546558945" expanded="true" signature="1492:1549" ph="{...}" />
360
+            <marker date="1487546558945" expanded="true" signature="1695:1831" ph="{...}" />
361
+            <marker date="1487546558945" expanded="true" signature="1908:2432" ph="{...}" />
362
+            <marker date="1487546558945" expanded="true" signature="1963:2421" ph="{...}" />
363
+            <marker date="1487546558945" expanded="true" signature="2225:2364" ph="{...}" />
364
+            <marker date="1487546558945" expanded="true" signature="2523:2682" ph="{...}" />
365
+            <marker date="1487546558945" expanded="true" signature="2825:3887" ph="{...}" />
366
+            <marker date="1487546558945" expanded="true" signature="3000:3086" ph="{...}" />
367
+            <marker date="1487546558945" expanded="true" signature="3146:3379" ph="{...}" />
368
+            <marker date="1487546558945" expanded="true" signature="3533:3833" ph="{...}" />
369
+            <marker date="1487546558945" expanded="true" signature="3629:3817" ph="{...}" />
370
+            <marker date="1487546558945" expanded="true" signature="3959:4013" ph="{...}" />
375 371
           </folding>
376 372
         </state>
377 373
       </provider>
@@ -643,6 +639,7 @@
643 639
       <provider selected="true" editor-type-id="text-editor">
644 640
         <state relative-caret-position="489">
645 641
           <caret line="39" column="42" lean-forward="true" selection-start-line="39" selection-start-column="42" selection-end-line="39" selection-end-column="42" />
642
+          <folding />
646 643
         </state>
647 644
       </provider>
648 645
     </entry>
@@ -836,45 +833,48 @@
836 833
         </state>
837 834
       </provider>
838 835
     </entry>
836
+    <entry file="file://$USER_HOME$/.local/share/JetBrains/Shared/v08/DecompilerCache/decompiler/68A505D3-EE90-4B2D-8432-759050F70CC3/8e/cee9fac8/LuResult`1.cs">
837
+      <provider selected="true" editor-type-id="text-editor">
838
+        <state relative-caret-position="180">
839
+          <caret line="10" column="15" lean-forward="false" selection-start-line="10" selection-start-column="15" selection-end-line="10" selection-end-column="15" />
840
+          <folding />
841
+        </state>
842
+      </provider>
843
+    </entry>
839 844
     <entry file="file://$PROJECT_DIR$/WebApiWebSem/DataAccess/ModelsDbo.cs">
840 845
       <provider selected="true" editor-type-id="text-editor">
841
-        <state relative-caret-position="450">
842
-          <caret line="34" column="30" lean-forward="false" selection-start-line="34" selection-start-column="30" selection-end-line="34" selection-end-column="30" />
843
-          <folding>
844
-            <marker date="1487540897085" expanded="true" signature="6:157" ph="..." />
845
-            <marker date="1487540897085" expanded="true" signature="192:1247" ph="{...}" />
846
-            <marker date="1487540897085" expanded="true" signature="228:1245" ph="{...}" />
847
-            <marker date="1487540897085" expanded="true" signature="308:600" ph="{...}" />
848
-            <marker date="1487540897085" expanded="true" signature="349:406" ph="{...}" />
849
-            <marker date="1487540897085" expanded="true" signature="460:589" ph="{...}" />
850
-            <marker date="1487540897085" expanded="true" signature="662:1239" ph="{...}" />
851
-            <marker date="1487540897085" expanded="true" signature="703:760" ph="{...}" />
852
-            <marker date="1487540897085" expanded="true" signature="808:1228" ph="{...}" />
853
-          </folding>
846
+        <state relative-caret-position="432">
847
+          <caret line="33" column="83" lean-forward="false" selection-start-line="33" selection-start-column="83" selection-end-line="33" selection-end-column="83" />
848
+          <folding />
854 849
         </state>
855 850
       </provider>
856 851
     </entry>
857 852
     <entry file="file://$PROJECT_DIR$/WebApiWebSem/DataAccess/ArticlesDataAccess.cs">
858 853
       <provider selected="true" editor-type-id="text-editor">
859
-        <state relative-caret-position="-113">
860
-          <caret line="48" column="69" lean-forward="true" selection-start-line="48" selection-start-column="69" selection-end-line="48" selection-end-column="69" />
854
+        <state relative-caret-position="445">
855
+          <caret line="105" column="43" lean-forward="true" selection-start-line="105" selection-start-column="43" selection-end-line="105" selection-end-column="43" />
861 856
           <folding>
862
-            <marker date="1487541118573" expanded="true" signature="6:273" ph="..." />
863
-            <marker date="1487541118573" expanded="true" signature="308:2856" ph="{...}" />
864
-            <marker date="1487541118573" expanded="true" signature="444:2854" ph="{...}" />
865
-            <marker date="1487541118573" expanded="true" signature="645:665" ph="{...}" />
866
-            <marker date="1487541118573" expanded="true" signature="717:760" ph="{...}" />
867
-            <marker date="1487541118573" expanded="true" signature="869:964" ph="{...}" />
868
-            <marker date="1487541118573" expanded="true" signature="1033:1085" ph="{...}" />
869
-            <marker date="1487541118573" expanded="true" signature="1145:1383" ph="{...}" />
870
-            <marker date="1487541118573" expanded="true" signature="1281:1338" ph="{...}" />
871
-            <marker date="1487541118573" expanded="true" signature="1484:1620" ph="{...}" />
872
-            <marker date="1487541118573" expanded="true" signature="1697:2221" ph="{...}" />
873
-            <marker date="1487541118573" expanded="true" signature="1752:2210" ph="{...}" />
874
-            <marker date="1487541118573" expanded="true" signature="2014:2153" ph="{...}" />
875
-            <marker date="1487541118573" expanded="true" signature="2312:2722" ph="{...}" />
876
-            <marker date="1487541118573" expanded="true" signature="2527:2666" ph="{...}" />
877
-            <marker date="1487541118573" expanded="true" signature="2794:2848" ph="{...}" />
857
+            <marker date="1487546558945" expanded="true" signature="6:307" ph="..." />
858
+            <marker date="1487546558945" expanded="true" signature="342:4021" ph="{...}" />
859
+            <marker date="1487546558945" expanded="true" signature="478:4019" ph="{...}" />
860
+            <marker date="1487546558945" expanded="true" signature="679:699" ph="{...}" />
861
+            <marker date="1487546558945" expanded="true" signature="751:794" ph="{...}" />
862
+            <marker date="1487546558945" expanded="true" signature="903:998" ph="{...}" />
863
+            <marker date="1487546558945" expanded="true" signature="1108:1175" ph="{...}" />
864
+            <marker date="1487546558945" expanded="true" signature="1244:1296" ph="{...}" />
865
+            <marker date="1487546558945" expanded="true" signature="1356:1594" ph="{...}" />
866
+            <marker date="1487546558945" expanded="true" signature="1492:1549" ph="{...}" />
867
+            <marker date="1487546558945" expanded="true" signature="1695:1831" ph="{...}" />
868
+            <marker date="1487546558945" expanded="true" signature="1908:2432" ph="{...}" />
869
+            <marker date="1487546558945" expanded="true" signature="1963:2421" ph="{...}" />
870
+            <marker date="1487546558945" expanded="true" signature="2225:2364" ph="{...}" />
871
+            <marker date="1487546558945" expanded="true" signature="2523:2682" ph="{...}" />
872
+            <marker date="1487546558945" expanded="true" signature="2825:3887" ph="{...}" />
873
+            <marker date="1487546558945" expanded="true" signature="3000:3086" ph="{...}" />
874
+            <marker date="1487546558945" expanded="true" signature="3146:3379" ph="{...}" />
875
+            <marker date="1487546558945" expanded="true" signature="3533:3833" ph="{...}" />
876
+            <marker date="1487546558945" expanded="true" signature="3629:3817" ph="{...}" />
877
+            <marker date="1487546558945" expanded="true" signature="3959:4013" ph="{...}" />
878 878
           </folding>
879 879
         </state>
880 880
       </provider>

+ 32
- 6
backend/WebSem/WebApiWebSem/DataAccess/ArticlesDataAccess.cs View File

@@ -4,6 +4,7 @@ using System.Linq;
4 4
 using System.Linq.Expressions;
5 5
 using Luticate2.Utils.DataAccess;
6 6
 using Luticate2.Utils.Dbo.Filter;
7
+using Luticate2.Utils.Dbo.Result;
7 8
 using Microsoft.EntityFrameworkCore;
8 9
 using WebApiWebSem.DataAccess.Models;
9 10
 using WebApiWebSem.Dbo.Articles;
@@ -28,6 +29,11 @@ namespace WebApiWebSem.DataAccess
28 29
             return table.Include(articles => articles.articles_fields_fk);
29 30
         }
30 31
 
32
+        protected override IQueryable<articles> GetEditQueryable(WsDbContext db, IQueryable<articles> table)
33
+        {
34
+            return GetGetQueryable(db, table);
35
+        }
36
+
31 37
         protected override DbSet<articles> GetTable(WsDbContext db)
32 38
         {
33 39
             return db.articles;
@@ -71,15 +77,35 @@ namespace WebApiWebSem.DataAccess
71 77
         {
72 78
             model.picture_caption = obj.PictureCaption;
73 79
             model.picture_url = obj.PictureUrl;
74
-            model.articles_fields_fk = obj.Fields.Select(dbo => new articles_fields
75
-                {
76
-                    value = dbo.Value,
77
-                    property = dbo.Property,
78
-                    type = dbo.Type
79
-                }).ToList();
80 80
             model.text = obj.Text;
81 81
         }
82 82
 
83
+        protected override LuResult<bool> _EditSingleById(articles model, ArticlesEditDbo update, WsDbContext db, IQueryable<articles> table)
84
+        {
85
+            foreach (var removed in model.articles_fields_fk.Where(fields => update.Fields.FirstOrDefault(dbo => dbo.Property == fields.property) == null).ToList())
86
+            {
87
+                model.articles_fields_fk.Remove(removed);
88
+            }
89
+            foreach (var field in model.articles_fields_fk)
90
+            {
91
+                var f = update.Fields.First(dbo => dbo.Property == field.property);
92
+                field.value = f.Value;
93
+                field.property = f.Property;
94
+                field.type = f.Type;
95
+            }
96
+            foreach (var added in update.Fields.Where(dbo => model.articles_fields_fk.FirstOrDefault(fields => dbo.Property == fields.property) == null))
97
+            {
98
+                model.articles_fields_fk.Add(new articles_fields
99
+                {
100
+                    value = added.Value,
101
+                    property = added.Property,
102
+                    type = added.Type,
103
+                    article_id = model.id
104
+                });
105
+            }
106
+            return LuResult<bool>.Ok(true);
107
+        }
108
+
83 109
         protected override ArticlesDbo GetDboFromModel(articles model)
84 110
         {
85 111
             return model.ToDbo();

+ 1
- 1
backend/WebSem/WebApiWebSem/DataAccess/ModelsDbo.cs View File

@@ -31,7 +31,7 @@ namespace WebApiWebSem.DataAccess
31 31
             return new ArticlesDbo
32 32
             {
33 33
                 CreatedAt = model.created_at.ToDbo(),
34
-                Fields = model.articles_fields_fk.Select(fields => fields.ToDbo()).ToList(),
34
+                Fields = model.articles_fields_fk.OrderBy(fields => fields.property).Select(fields => fields.ToDbo()).ToList(),
35 35
                 Id = model.id,
36 36
                 PictureCaption = model.picture_caption,
37 37
                 PictureUrl = model.picture_url,

Loading…
Cancel
Save