public static IMemberType BuildMemberTypeEntity(IShortStringHelper shortStringHelper, ContentTypeDto dto) { var contentType = new MemberType(shortStringHelper, dto.NodeDto.ParentId); try { contentType.DisableChangeTracking(); BuildCommonEntity(contentType, dto, false); contentType.ResetDirtyProperties(false); } finally { contentType.EnableChangeTracking(); } return(contentType); }
public static IMemberType BuildEntity(MemberTypeReadOnlyDto dto, out bool needsSaving) { var standardPropertyTypes = Constants.Conventions.Member.GetStandardPropertyTypeStubs(); needsSaving = false; var memberType = new MemberType(dto.ParentId); try { memberType.DisableChangeTracking(); memberType.Alias = dto.Alias; memberType.AllowedAsRoot = dto.AllowAtRoot; memberType.CreateDate = dto.CreateDate; memberType.CreatorId = dto.UserId.HasValue ? dto.UserId.Value : 0; memberType.Description = dto.Description; memberType.Icon = dto.Icon; memberType.Id = dto.NodeId; memberType.IsContainer = dto.IsContainer; memberType.Key = dto.UniqueId.Value; memberType.Level = dto.Level; memberType.Name = dto.Text; memberType.Path = dto.Path; memberType.SortOrder = dto.SortOrder; memberType.Thumbnail = dto.Thumbnail; memberType.Trashed = dto.Trashed; memberType.UpdateDate = dto.CreateDate; memberType.AllowedContentTypes = Enumerable.Empty <ContentTypeSort>(); var propertyTypeGroupCollection = GetPropertyTypeGroupCollection(dto, memberType, standardPropertyTypes); memberType.PropertyGroups = propertyTypeGroupCollection; var propertyTypes = GetPropertyTypes(dto, memberType, standardPropertyTypes); //By Convention we add 9 stnd PropertyTypes - This is only here to support loading of types that didn't have these conventions before. foreach (var standardPropertyType in standardPropertyTypes) { if (dto.PropertyTypes.Any(x => x.Alias.Equals(standardPropertyType.Key))) { continue; } // beware! // means that we can return a memberType "from database" that has some property types // that do *not* come from the database and therefore are incomplete eg have no key, // no id, no dataTypeDefinitionId - ouch! - better notify caller of the situation needsSaving = true; //Add the standard PropertyType to the current list propertyTypes.Add(standardPropertyType.Value); //Internal dictionary for adding "MemberCanEdit", "VisibleOnProfile", "IsSensitive" properties to each PropertyType memberType.MemberTypePropertyTypes.Add(standardPropertyType.Key, new MemberTypePropertyProfileAccess(false, false, false)); } memberType.NoGroupPropertyTypes = propertyTypes; return(memberType); } finally { memberType.EnableChangeTracking(); } }