made static, however this has been refactored will need extra sanity checking to ensure nothing has been broken

This commit is contained in:
Ismail Mayat
2018-06-29 14:30:20 +01:00
parent 2a532e6993
commit 79ce8a29ae
2 changed files with 156 additions and 172 deletions

View File

@@ -191,13 +191,12 @@ AND umbracoNode.nodeObjectType = @objectType",
SortOrder = allowedContentType.SortOrder
});
}
var propertyFactory = new PropertyGroupFactory(nodeDto.NodeId);
//Insert Tabs
foreach (var propertyGroup in entity.PropertyGroups)
{
var tabDto = propertyFactory.BuildGroupDto(propertyGroup);
var tabDto = PropertyGroupFactory.BuildGroupDto(propertyGroup, nodeDto.NodeId);
var primaryKey = Convert.ToInt32(Database.Insert(tabDto));
propertyGroup.Id = primaryKey;//Set Id on PropertyGroup
@@ -222,7 +221,7 @@ AND umbracoNode.nodeObjectType = @objectType",
{
AssignDataTypeFromPropertyEditor(propertyType);
}
var propertyTypeDto = propertyFactory.BuildPropertyTypeDto(tabId, propertyType);
var propertyTypeDto = PropertyGroupFactory.BuildPropertyTypeDto(tabId, propertyType, nodeDto.NodeId);
int typePrimaryKey = Convert.ToInt32(Database.Insert(propertyTypeDto));
propertyType.Id = typePrimaryKey; //Set Id on new PropertyType
@@ -384,13 +383,12 @@ AND umbracoNode.id <> @id",
Database.Delete<PropertyTypeGroupDto>("WHERE id IN (@ids)", new { ids = groupsToDelete });
}
}
var propertyGroupFactory = new PropertyGroupFactory(entity.Id);
// insert or update groups, assign properties
foreach (var propertyGroup in entity.PropertyGroups)
{
// insert or update group
var groupDto = propertyGroupFactory.BuildGroupDto(propertyGroup);
var groupDto = PropertyGroupFactory.BuildGroupDto(propertyGroup,entity.Id);
var groupId = propertyGroup.HasIdentity
? Database.Update(groupDto)
: Convert.ToInt32(Database.Insert(groupDto));
@@ -419,7 +417,7 @@ AND umbracoNode.id <> @id",
ValidateAlias(propertyType);
// insert or update property
var propertyTypeDto = propertyGroupFactory.BuildPropertyTypeDto(groupId, propertyType);
var propertyTypeDto = PropertyGroupFactory.BuildPropertyTypeDto(groupId, propertyType, entity.Id);
var typeId = propertyType.HasIdentity
? Database.Update(propertyTypeDto)
: Convert.ToInt32(Database.Insert(propertyTypeDto));
@@ -480,8 +478,8 @@ AND umbracoNode.id <> @id",
var dtos = Database
.Fetch<PropertyTypeGroupDto>(sql);
var propertyGroupFactory = new PropertyGroupFactory(id, createDate, updateDate, CreatePropertyType);
var propertyGroups = propertyGroupFactory.BuildEntity(dtos, IsPublishing);
var propertyGroups = PropertyGroupFactory.BuildEntity(dtos, IsPublishing, id, createDate, updateDate,CreatePropertyType);
return new PropertyGroupCollection(propertyGroups);
}