public async Task <IActionResult> AddWorkflowDimension(long workflowConfigId, [FromBody] WorkflowDimension workflowDimension)
        {
            try
            {
                HttpResponseMessageResult res = new HttpResponseMessageResult()
                {
                    IsSuccess = true
                };
                workflowDimension = await Adapter.AddWorkflowDimension(workflowConfigId, workflowDimension);

                res.GetObjectForJson(workflowDimension);

                return(Ok(res));
            }
            catch (Exception ex)
            {
                Logger.LogError(LoggingEvents.CRITICAL_ERROR, ex.Message, ex);
                return(StatusCode(500, ex.Message));
            }
        }
        /// <summary>
        /// Duplique un WorkflowConfig, en laissant dans la copie l'id du WorkflowConfig d'origine.
        /// </summary>
        /// <param name="workflowConfig">WorkflowConfig à copier</param>
        /// <returns>WorkflowConfig dupliqué</returns>
        public async Task <WorkflowConfig> CopyForStatic(WorkflowConfig workflowConfig)
        {
            if (workflowConfig == null)
            {
                throw new WrongParameterException("WorkflowConfigDomain.CopyForStatic: WorkflowConfig source is null!");
            }
            if (workflowConfig.IdWorkflowConfigOriginal.HasValue)
            {
                throw new WrongParameterException("WorkflowConfigDomain.CopyForStatic: WorkflowConfig source isn't orignal!");
            }

            List <WorkflowConfig> lstSearch = await UnitOfWork.GetDbContext().WorkflowConfig
                                              .Where(wf => wf.Name.Contains(workflowConfig.Name) && wf.IdWorkflowConfigOriginal.HasValue)
                                              .AsNoTracking()
                                              .ToAsyncEnumerable()
                                              .ToList();

            int        lastNumber = 1;
            List <int> allNumbers = new List <int>();

            foreach (WorkflowConfig wf in lstSearch)
            {
                Match m = _regexSubstringName.Match(wf.Name);
                if (m.Success)
                {
                    string name = m.Groups["name"].Value;
                    if (name == workflowConfig.Name)
                    {
                        if (Int32.TryParse(m.Groups["number"].Value, out int number))
                        {
                            allNumbers.Add(number);
                        }
                    }
                }
            }

            if (allNumbers.Count > 0)
            {
                lastNumber = allNumbers.Max() + 1;
            }

            WorkflowConfig duplicat = new WorkflowConfig();

            UnitOfWork.WorkflowConfigRepository.PrepareAddForObject(duplicat);

            duplicat.Name = string.Format(Constant.POSTFIX_NAME_DUPLICATE_WORKFLOW_CONFIG, workflowConfig.Name, lastNumber);
            duplicat.IdWorkflowConfigOriginal = workflowConfig.Id;
            duplicat.ActionSequenceRef        = workflowConfig.ActionSequenceRef;
            duplicat.ConstraintSequenceRef    = workflowConfig.ConstraintSequenceRef;
            foreach (SelectorConfig sc in workflowConfig.SelectorConfig)
            {
                SelectorConfig scNew = await SelectorConfigDomain.CopyForStatic(sc);

                scNew.WorkflowConfig = duplicat;
                duplicat.SelectorConfig.Add(scNew);
            }
            foreach (WorkflowDimension wd in workflowConfig.WorkflowDimension)
            {
                WorkflowDimension wfNew = await WorkflowDimensionDomain.CopyForStatic(wd);

                wfNew.WorkflowConfig = duplicat;
                duplicat.WorkflowDimension.Add(wfNew);
            }
            List <GridConfig> lstGridConf = await UnitOfWork.GetDbContext().GridConfig
                                            .Where(gc => gc.WorkflowConfig.Id == workflowConfig.Id)
                                            .Include(gc => gc.ColumnDimensions)
                                            .ThenInclude(gd => gd.Values)
                                            .Include(gc => gc.RowDimensions)
                                            .ThenInclude(gd => gd.Values)
                                            .Include(gc => gc.FixedDimensions)
                                            .ThenInclude(gd => gd.Values)
                                            .AsNoTracking()
                                            .ToAsyncEnumerable()
                                            .ToList();

            GridConfig gridConf = lstGridConf.FirstOrDefault();

            if (gridConf != null)
            {
                GridConfig gridConfNew = await GridConfigurationDomain.CopyForStatic(gridConf);

                gridConfNew.WorkflowConfig = duplicat;
            }

            int nbr = await UnitOfWork.GetDbContext().SaveChangesAsync();

            return(duplicat);
        }