@@ -51,11 +51,12 @@ public OperationResult CreateEntityGroup(AdvEntitySelectableGroupEditModel editM
5151 var nextItemUid = entityGroup . EntityGroupItemLst . Count ;
5252 foreach ( var entityItem in editModel . AdvEntitySelectableItemModels )
5353 {
54- entityGroup . EntityGroupItemLst . Add ( new EntityItem ( entityItem . Name ,
55- entityItem . Description , nextItemUid . ToString ( ) , Constants . WorkflowStates . Created ) ) ;
54+ core . EntitySelectItemCreate ( entityGroup . Id , entityItem . Name , entityItem . DisplayIndex , nextItemUid . ToString ( ) ) ;
55+ //entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
56+ // entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
5657 nextItemUid ++ ;
5758 }
58- core . EntityGroupUpdate ( entityGroup ) ;
59+ // core.EntityGroupUpdate(entityGroup);
5960 }
6061 return new OperationResult ( true , LocaleHelper . GetString ( "ParamCreatedSuccessfully" , groupCreate . MicrotingUUID ) ) ;
6162 }
@@ -73,9 +74,33 @@ public OperationResult UpdateEntityGroup(AdvEntitySelectableGroupEditModel editM
7374 {
7475 var core = _coreHelper . GetCore ( ) ;
7576 var entityGroup = core . EntityGroupRead ( editModel . GroupUid ) ;
76- entityGroup . EntityGroupItemLst = editModel . AdvEntitySelectableItemModels ;
77- entityGroup . Name = editModel . Name ;
78- core . EntityGroupUpdate ( entityGroup ) ;
77+
78+ if ( editModel . AdvEntitySelectableItemModels . Any ( ) )
79+ {
80+ var nextItemUid = entityGroup . EntityGroupItemLst . Count ;
81+ List < int > currentIds = new List < int > ( ) ;
82+ foreach ( EntityItem entityItem in editModel . AdvEntitySelectableItemModels )
83+ {
84+ if ( string . IsNullOrEmpty ( entityItem . MicrotingUUID ) )
85+ {
86+ EntityItem et = core . EntitySelectItemCreate ( entityGroup . Id , entityItem . Name , entityItem . DisplayIndex , nextItemUid . ToString ( ) ) ;
87+ currentIds . Add ( et . Id ) ;
88+ }
89+ else
90+ {
91+ core . EntityItemUpdate ( entityItem . Id , entityItem . Name , entityItem . Description , entityItem . EntityItemUId , entityItem . DisplayIndex ) ;
92+ currentIds . Add ( entityItem . Id ) ;
93+ }
94+ nextItemUid ++ ;
95+ }
96+ foreach ( EntityItem entityItem in entityGroup . EntityGroupItemLst )
97+ {
98+ if ( ! currentIds . Contains ( entityItem . Id ) )
99+ {
100+ core . EntityItemDelete ( entityItem . Id ) ;
101+ }
102+ }
103+ }
79104 return new OperationResult ( true , LocaleHelper . GetString ( "ParamUpdatedSuccessfully" , editModel . GroupUid ) ) ;
80105 }
81106 catch ( Exception )
0 commit comments