/// <summary>
        /// Set start state for entry on all registered workflows
        /// </summary>
        /// <param name="entityName"></param>
        /// <param name="entryId"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel> SetStartStateForEntryAsync([Required] string entityName, [Required] string entryId)
        {
            var contractRequest = await GetEntityContractsAsync(entityName);

            if (!contractRequest.IsSuccess)
            {
                return(contractRequest.ToBase());
            }
            var contracts = contractRequest.Result;

            foreach (var contract in contracts.Where(x => x.WorkFlow.Enabled).ToList())
            {
                var workflowRequest = await _workFlowCreatorService.GetWorkFlowByIdAsync(contract.WorkFlowId);

                if (!workflowRequest.IsSuccess)
                {
                    continue;
                }
                var workflow   = workflowRequest.Result;
                var startState = workflow.States.FirstOrDefault(x => x.IsStartState);
                if (startState == null)
                {
                    continue;
                }
                await _workFlowContext.EntryStates.AddAsync(new EntryState
                {
                    EntryId    = entryId,
                    StateId    = startState.Id,
                    ContractId = contract.Id,
                });
            }

            return(await _workFlowContext.PushAsync());
        }
        /// <summary>
        /// Add new workflow
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel <Guid> > AddNewWorkflowAsync(AddNewWorkflowViewModel model)
        {
            Arg.NotNull(model, nameof(AddNewWorkflowViewModel));
            var workflow = WorkFlowMapper.Map(model);
            await _workFlowContext.WorkFlows.AddAsync(workflow);

            var dbRequest = await _workFlowContext.PushAsync();

            return(dbRequest.Map(workflow.Id));
        }