public bool Create(Domain.SerialNumberRule entity) { //检查是否已存在相同字段的编码规则 if (_serialNumberRuleRepository.Exists(x => x.EntityId == entity.EntityId && x.AttributeId == entity.AttributeId)) { throw new XmsException(_loc["serial_number_duplicated"]); } entity.OrganizationId = this._appContext.OrganizationId; var result = true; using (UnitOfWork.Build(_serialNumberRuleRepository.DbContext)) { result = _serialNumberRuleRepository.Create(entity); //依赖于字段 _dependencyService.Create(entity); //solution component result = _solutionComponentService.Create(entity.SolutionId, entity.SerialNumberRuleId, SerialNumberRuleDefaults.ModuleName); //本地化标签 _localizedLabelService.Create(entity.SolutionId, entity.Name.IfEmpty(""), SerialNumberRuleDefaults.ModuleName, "LocalizedName", entity.SerialNumberRuleId, this._appContext.BaseLanguage); _localizedLabelService.Create(entity.SolutionId, entity.Description.IfEmpty(""), SerialNumberRuleDefaults.ModuleName, "Description", entity.SerialNumberRuleId, this._appContext.BaseLanguage); //plugin _entityPluginCreater.Create(new EntityPlugin() { AssemblyName = SerialNumberRuleDefaults.AssemblyName , ClassName = SerialNumberRuleDefaults.PluginClassName , EntityId = entity.EntityId , EventName = Enum.GetName(typeof(OperationTypeEnum), OperationTypeEnum.Create) , IsVisibled = false , TypeCode = 0 , StateCode = RecordState.Enabled }); //add to cache _cacheService.SetEntity(_serialNumberRuleRepository.FindById(entity.SerialNumberRuleId)); } return(result); }
public bool Update(Domain.SerialNumberRule entity) { //检查是否已存在相同字段的编码规则 if (_serialNumberRuleRepository.Exists(x => x.SerialNumberRuleId != entity.SerialNumberRuleId && x.EntityId == entity.EntityId && x.AttributeId == entity.AttributeId)) { throw new XmsException(_loc["serial_number_duplicated"]); } bool result = _serialNumberRuleRepository.Update(entity); if (result) { //依赖于字段 _dependencyService.Update(entity); //localization _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.SerialNumberRuleId, this._appContext.BaseLanguage); _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.SerialNumberRuleId, this._appContext.BaseLanguage); //set to cache _cacheService.SetEntity(_serialNumberRuleRepository.FindById(entity.SerialNumberRuleId)); } return(result); }
public bool Update(Domain.SerialNumberRule entity) { //依赖于字段 return(_dependencyService.Update(SerialNumberRuleDefaults.ModuleName, entity.SerialNumberRuleId, AttributeDefaults.ModuleName, entity.AttributeId)); }