Beispiel #1
0
        public int Add(Dto.ProcessDefinitionWithRole input)
        {
            var deletedRoleProcessDefinition = _roleProcessDefinitionRepository.Get().Where(u => u.ProcessDefinition.Name == input.ProcessDefinition.Name).ToList();
            int id = 0;

            using (var transaction = _dbContextProvider.BeginTransaction())
            {
                id = _definitionProvider.DeployNewProcessDefinition(input.ProcessDefinition);
                var roleProcessDefinitions = input.RoleIds.Select(u => new RoleProcessDefinition
                {
                    ProcessDefinitionId = id,
                    RoleId = u
                }).ToList();

                _roleProcessDefinitionRepository.BatchDelete(deletedRoleProcessDefinition);
                _roleProcessDefinitionRepository.BatchAdd(roleProcessDefinitions);
                transaction.Commit();
            }
            return(id);
        }