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

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

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

                    var nextItemUid = entityGroup.EntityGroupItemLst.Count;
                    foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
                    {
                        await core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description,
                                                          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("SearchableListCreationFailed")));
            }
        }
        public OperationResult CreateEntityGroup(AdvEntitySearchableGroupEditModel editModel)
        {
            try
            {
                eFormCore.Core core        = _coreHelper.GetCore();
                EntityGroup    groupCreate = core.EntityGroupCreate(Constants.FieldTypes.EntitySearch, editModel.Name);
                if (editModel.AdvEntitySearchableItemModels.Any())
                {
                    EntityGroup entityGroup = core.EntityGroupRead(groupCreate.MicrotingUUID);
                    int         nextItemUid = entityGroup.EntityGroupItemLst.Count;
                    foreach (EntityItem entityItem in editModel.AdvEntitySearchableItemModels)
                    {
                        core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description,
                                                    nextItemUid.ToString());

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

                    //core.EntityGroupUpdate(entityGroup);
                }

                return(new OperationResult(true,
                                           LocaleHelper.GetString("ParamCreatedSuccessfully", groupCreate.MicrotingUUID)));
            }
            catch (Exception)
            {
                return(new OperationResult(false, LocaleHelper.GetString("SearchableListCreationFailed")));
            }
        }
 public OperationResult CreateEntityGroup(AdvEntitySearchableGroupEditModel editModel)
 {
     try
     {
         var core        = _coreHelper.GetCore();
         var groupCreate = core.EntityGroupCreate(Constants.FieldTypes.EntitySearch, editModel.Name);
         if (editModel.AdvEntitySearchableItemModels.Any())
         {
             var entityGroup = core.EntityGroupRead(groupCreate.EntityGroupMUId);
             var nextItemUid = entityGroup.EntityGroupItemLst.Count;
             foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
             {
                 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(AdvEntitySearchableGroupEditModel editModel)
        {
            try
            {
                var core = await _coreHelper.GetCore();

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

                entityGroup.Description = editModel.Description;
                entityGroup.Name        = editModel.Name;
                await core.EntityGroupUpdate(entityGroup);

                var currentIds = new List <int>();

                foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
                {
                    if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
                    {
                        var et = await core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name,
                                                                   entityItem.Description, 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)
            {
                return(new OperationResult(false, _localizationService.GetString("SearchableListCreationFailed")));
            }
        }
 public OperationResult UpdateEntityGroup(AdvEntitySearchableGroupEditModel editModel)
 {
     try
     {
         var core        = _coreHelper.GetCore();
         var entityGroup = core.EntityGroupRead(editModel.GroupUid);
         entityGroup.EntityGroupItemLst = editModel.AdvEntitySearchableItemModels;
         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(AdvEntitySearchableGroupEditModel editModel)
        {
            try
            {
                eFormCore.Core core        = _coreHelper.GetCore();
                EntityGroup    entityGroup = core.EntityGroupRead(editModel.GroupUid);

                int        nextItemUid = entityGroup.EntityGroupItemLst.Count;
                List <int> currentIds  = new List <int>();

                foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
                {
                    if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
                    {
                        EntityItem et = core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name,
                                                                    entityItem.Description, 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("SearchableListCreationFailed")));
            }
        }
 public Task <OperationResult> Update([FromBody] AdvEntitySearchableGroupEditModel editModel)
 {
     return(_entitySearchService.Update(editModel));
 }