Пример #1
0
        public CreatedStageContract Create(CreateStageContract contract)
        {
            _log.LogInformation($"Validating contract {contract.Status}");
            ValidateContract(contract);


            _log.LogInformation($"Mapping contract {contract.Status}");
            var stage = _mapper.Map <Stage>(contract);

            var createdStage = _processStageRepository.Create(stage);

            _log.LogInformation($"Complete for {contract.Status}");
            _unitOfWork.Complete();

            var createdStageContract = _mapper.Map <CreatedStageContract>(createdStage);

            _log.LogInformation($"Return {contract.Status}");
            return(createdStageContract);
        }
Пример #2
0
        public bool Create(ProcessStage entity)
        {
            var result = true;

            using (UnitOfWork.Build(_processStageRepository.DbContext))
            {
                result = _processStageRepository.Create(entity);
                //依赖于实体
                _dependencyService.Create(WorkFlowDefaults.ModuleName, entity.WorkFlowId, EntityDefaults.ModuleName, entity.EntityId);
                //依赖于字段
                var st = new List <ProcessStep>().DeserializeFromJson(entity.Steps);
                if (st.NotEmpty())
                {
                    var attrNames  = st.Select(x => x.AttributeName).ToArray();
                    var attributes = _attributeFinder.FindByName(entity.EntityId, attrNames);
                    var attrIds    = attributes.Select(x => x.AttributeId).ToArray();
                    _dependencyService.Create(WorkFlowDefaults.ModuleName, entity.WorkFlowId, AttributeDefaults.ModuleName, attrIds);
                }
            }

            return(result);
        }