Field IFieldRepository.CreateNew(Field item, bool explicitOrder) { try { if (explicitOrder) { ChangeMaxOrderTriggerState(false); item.ReorderContentFields(); } var constraint = item.Constraint; var dynamicImage = item.DynamicImage; DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.Field, item); var newItem = DefaultRepository.Save <Field, FieldDAL>(item); DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.Field); if (explicitOrder) { UpdateFieldOrder(newItem.Id, item.Order); } SaveConstraint(constraint, newItem); SaveDynamicImage(dynamicImage, newItem); return(GetById(newItem.Id)); } finally { if (explicitOrder) { ChangeMaxOrderTriggerState(true); } } }
Field IFieldRepository.CreateNew(Field item, bool explicitOrder) { using (var scope = new QPConnectionScope()) { try { if (QPContext.DatabaseType == DatabaseType.SqlServer) { ChangeMaxOrderTriggerState(scope.DbConnection, false); ChangeInsertFieldTriggerState(scope.DbConnection, false); ChangeM2MDefaultTriggerState(scope.DbConnection, false); } if (explicitOrder) { item.ReorderContentFields(); } else { var fieldsExists = QPContext.EFContext.FieldSet.Any(n => n.ContentId == item.ContentId); var maxOrder = fieldsExists ? (int)QPContext.EFContext.FieldSet.Where(n => n.ContentId == item.ContentId) .Select(n => n.Order).Max() : 0; item.Order = maxOrder + 1; } var constraint = item.Constraint; var dynamicImage = item.DynamicImage; var fieldValues = item.QpPluginFieldValues; DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.Field, item); var newItem = DefaultRepository.Save <Field, FieldDAL>(item); var field = GetDal(newItem); Common.AddColumn(scope.DbConnection, field); DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.Field); SaveConstraint(constraint, newItem); SaveDynamicImage(dynamicImage, newItem); UpdatePluginValues(fieldValues, newItem.Id); return(GetById(newItem.Id)); } finally { if (QPContext.DatabaseType == DatabaseType.SqlServer) { ChangeMaxOrderTriggerState(scope.DbConnection, true); ChangeInsertFieldTriggerState(scope.DbConnection, true); ChangeM2MDefaultTriggerState(scope.DbConnection, true); } } } }
internal static ContentGroup SaveGroup(ContentGroup group) { var dal = MapperFacade.ContentGroupMapper.GetDalObject(group); DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.ContentGroup, group); if (group.ForceId != 0) { dal.Id = group.ForceId; } var newDal = DefaultRepository.SimpleSave(dal); DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.ContentGroup); return(MapperFacade.ContentGroupMapper.GetBizObject(newDal)); }
ContentLink IContentRepository.SaveLink(ContentLink link) { EntityObject.VerifyIdentityInserting(EntityTypeCode.ContentLink, link.LinkId, link.ForceLinkId); if (link.ForceLinkId != 0) { link.LinkId = link.ForceLinkId; } DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.ContentLink); var result = MapperFacade.ContentLinkMapper.GetBizObject(DefaultRepository.SimpleSave(MapperFacade.ContentLinkMapper.GetDalObject(link))); DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.ContentLink); result.WasNew = true; return(result); }
internal static Content Save(Content content, bool createDefaultField) { var binding = content.WorkflowBinding; FieldRepository.ChangeCreateFieldsTriggerState(false); DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.Content, content); var newContent = DefaultRepository.Save <Content, ContentDAL>(content); DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.Content); FieldRepository.ChangeCreateFieldsTriggerState(true); if (createDefaultField) { CreateDefaultField(newContent, content.ForceFieldIds); } binding.SetContent(newContent); WorkflowRepository.UpdateContentWorkflowBind(binding); return(GetById(newContent.Id)); }