public async Task <OperationResult> Create(AdvEntitySelectableGroupEditModel editModel)
        {
            try
            {
                var core = await _coreHelper.GetCore();

                var groupCreate = await core.EntityGroupCreate(Constants.FieldTypes.EntitySelect, editModel.Name, editModel.Description);

                if (editModel.AdvEntitySelectableItemModels.Any())
                {
                    var entityGroup = await core.EntityGroupRead(groupCreate.MicrotingUUID);

                    var nextItemUid = entityGroup.EntityGroupItemLst.Count;
                    foreach (var entityItem in editModel.AdvEntitySelectableItemModels)
                    {
                        await core.EntitySelectItemCreate(entityGroup.Id, entityItem.Name, entityItem.DisplayIndex,
                                                          nextItemUid.ToString());

                        //entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
                        //    entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
                        nextItemUid++;
                    }

                    //core.EntityGroupUpdate(entityGroup);
                }

                return(new OperationResult(true,
                                           _localizationService.GetStringWithFormat("ParamCreatedSuccessfully", groupCreate.MicrotingUUID)));
            }
            catch (Exception)
            {
                return(new OperationResult(false, _localizationService.GetString("SelectableListCreationFailed")));
            }
        }
 public OperationResult CreateEntityGroup(AdvEntitySelectableGroupEditModel editModel)
 {
     try
     {
         var core        = _coreHelper.GetCore();
         var groupCreate = core.EntityGroupCreate(Constants.FieldTypes.EntitySelect, editModel.Name);
         if (editModel.AdvEntitySelectableItemModels.Any())
         {
             var entityGroup = core.EntityGroupRead(groupCreate.EntityGroupMUId);
             var nextItemUid = entityGroup.EntityGroupItemLst.Count;
             foreach (var entityItem in editModel.AdvEntitySelectableItemModels)
             {
                 entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
                                                                   entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
                 nextItemUid++;
             }
             core.EntityGroupUpdate(entityGroup);
         }
         return(new OperationResult(true, $"{groupCreate.EntityGroupMUId} created successfully"));
     }
     catch (Exception)
     {
         return(new OperationResult(false, "Searchable list creation failed"));
     }
 }
        public async Task <OperationResult> Update(AdvEntitySelectableGroupEditModel editModel)
        {
            try
            {
                var core = await _coreHelper.GetCore();

                var entityGroup = await core.EntityGroupRead(editModel.GroupUid);

                entityGroup.Description = editModel.Description;
                // if (entityGroup.Name != editModel.Name)
                // {
                entityGroup.Name = editModel.Name;
                await core.EntityGroupUpdate(entityGroup);

                // }


                var currentIds = new List <int>();

                foreach (var entityItem in editModel.AdvEntitySelectableItemModels)
                {
                    if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
                    {
                        var et = core.EntitySelectItemCreate(entityGroup.Id, entityItem.Name,
                                                             entityItem.DisplayIndex, entityItem.DisplayIndex.ToString());
                        currentIds.Add(et.Id);
                    }
                    else
                    {
                        await core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description,
                                                    entityItem.DisplayIndex.ToString(), entityItem.DisplayIndex);

                        currentIds.Add(entityItem.Id);
                    }
                }

                foreach (var entityItem in entityGroup.EntityGroupItemLst)
                {
                    if (!currentIds.Contains(entityItem.Id))
                    {
                        await core.EntityItemDelete(entityItem.Id);
                    }
                }

                return(new OperationResult(true,
                                           _localizationService.GetStringWithFormat("ParamUpdatedSuccessfully", editModel.GroupUid)));
            }
            catch (Exception exception)
            {
                return(new OperationResult(false, _localizationService.GetString("SelectableListCreationFailed") + exception.Message));
            }
        }
 public OperationResult UpdateEntityGroup(AdvEntitySelectableGroupEditModel editModel)
 {
     try
     {
         var core        = _coreHelper.GetCore();
         var entityGroup = core.EntityGroupRead(editModel.GroupUid);
         entityGroup.EntityGroupItemLst = editModel.AdvEntitySelectableItemModels;
         entityGroup.Name = editModel.Name;
         core.EntityGroupUpdate(entityGroup);
         return(new OperationResult(true, $"{editModel.GroupUid} updated successfully"));
     }
     catch (Exception)
     {
         return(new OperationResult(false, "Searchable list creation failed"));
     }
 }
        public OperationResult UpdateEntityGroup(AdvEntitySelectableGroupEditModel editModel)
        {
            try
            {
                eFormCore.Core core        = _coreHelper.GetCore();
                EntityGroup    entityGroup = core.EntityGroupRead(editModel.GroupUid);

                if (editModel.AdvEntitySelectableItemModels.Any())
                {
                    var        nextItemUid = entityGroup.EntityGroupItemLst.Count;
                    List <int> currentIds  = new List <int>();
                    foreach (EntityItem entityItem in editModel.AdvEntitySelectableItemModels)
                    {
                        if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
                        {
                            EntityItem et = core.EntitySelectItemCreate(entityGroup.Id, entityItem.Name, entityItem.DisplayIndex, nextItemUid.ToString());
                            currentIds.Add(et.Id);
                        }
                        else
                        {
                            core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description, entityItem.EntityItemUId, entityItem.DisplayIndex);
                            currentIds.Add(entityItem.Id);
                        }
                        nextItemUid++;
                    }
                    foreach (EntityItem entityItem in entityGroup.EntityGroupItemLst)
                    {
                        if (!currentIds.Contains(entityItem.Id))
                        {
                            core.EntityItemDelete(entityItem.Id);
                        }
                    }
                }
                return(new OperationResult(true, LocaleHelper.GetString("ParamUpdatedSuccessfully", editModel.GroupUid)));
            }
            catch (Exception)
            {
                return(new OperationResult(false, LocaleHelper.GetString("SelectableListCreationFailed")));
            }
        }
 public Task <OperationResult> Update([FromBody] AdvEntitySelectableGroupEditModel editModel)
 {
     return(_entitySelectService.Update(editModel));
 }