private void RemoveItem(DataAccess.EntityUIComposition item, DataAccess.MyProjectEntities projectContext) { foreach (var cItem in item.EntityUIComposition1) { RemoveItem(cItem, projectContext); } if (item.ColumnUISetting != null) { projectContext.ColumnUISetting.Remove(item.ColumnUISetting); } if (item.RelationshipUISetting != null) { projectContext.RelationshipUISetting.Remove(item.RelationshipUISetting); } if (item.TabGroupUISetting != null) { projectContext.TabGroupUISetting.Remove(item.TabGroupUISetting); } if (item.EmptySpaceUISetting != null) { projectContext.EmptySpaceUISetting.Remove(item.EmptySpaceUISetting); } if (item.GroupUISetting != null) { projectContext.GroupUISetting.Remove(item.GroupUISetting); } if (item.TabPageUISetting != null) { projectContext.TabPageUISetting.Remove(item.TabPageUISetting); } if (item.EntityUISetting != null) { projectContext.EntityUISetting.Remove(item.EntityUISetting); } projectContext.EntityUIComposition.Remove(item); }
//public List<EntityUICompositionDTO> GetEntityUIComposition(int? parentID) //{ // List<EntityUICompositionDTO> result = new List<EntityUICompositionDTO>(); // using (var projectContext = new DataAccess.MyProjectEntities()) // { // var list = projectContext.EntityUIComposition.Where(x => x.ParentID == parentID); // foreach (var item in list) // { // result.Add(ToEntityUICompositionDTO(item, false)); // } // } // return result; //} private EntityUICompositionDTO ToEntityUICompositionDTO(DataAccess.EntityUIComposition item, bool withChilds, List <ColumnUISettingDTO> columnItems = null, List <RelationshipUISettingDTO> relationshipItems = null) { var result = new EntityUICompositionDTO(); result.ID = item.ID; result.ParentID = item.ParentID; result.ObjectIdentity = item.ItemIdentity; result.Title = item.ItemTitle; result.ObjectCategory = (DatabaseObjectCategory)Enum.Parse(typeof(DatabaseObjectCategory), item.Category); result.Position = item.Position; if (result.ObjectCategory == DatabaseObjectCategory.Entity) { if (item.EntityUISetting != null) { result.EntityUISetting = new EntityUISettingDTO(); result.EntityUISetting.ID = item.EntityUISetting.ID; result.EntityUISetting.UIColumnsCount = item.EntityUISetting.UIColumnsCount; } } else if (result.ObjectCategory == DatabaseObjectCategory.Column) { if (item.ColumnUISetting != null) { result.ColumnUISetting = new ColumnUISettingDTO(); result.ColumnUISetting.ID = item.ColumnUISetting.ID; result.ColumnUISetting.ColumnID = Convert.ToInt32(item.ItemIdentity); result.ColumnUISetting.UIColumnsType = (Enum_UIColumnsType)item.ColumnUISetting.UIColumnsType; result.ColumnUISetting.UIRowsCount = item.ColumnUISetting.UIRowsCount; if (columnItems != null) { columnItems.Add(result.ColumnUISetting); } } } else if (result.ObjectCategory == DatabaseObjectCategory.Relationship) { if (item.RelationshipUISetting != null) { result.RelationshipUISetting = new RelationshipUISettingDTO(); result.RelationshipUISetting.ID = item.RelationshipUISetting.ID; result.RelationshipUISetting.RelationshipID = Convert.ToInt32(item.ItemIdentity); result.RelationshipUISetting.UIColumnsType = (Enum_UIColumnsType)item.RelationshipUISetting.UIColumnsType; result.RelationshipUISetting.Expander = item.RelationshipUISetting.Expander; result.RelationshipUISetting.IsExpanded = item.RelationshipUISetting.IsExpanded == true; result.RelationshipUISetting.UIRowsCount = Convert.ToInt16(item.RelationshipUISetting.UIRowsCount); if (relationshipItems != null) { relationshipItems.Add(result.RelationshipUISetting); } } } else if (result.ObjectCategory == DatabaseObjectCategory.Group) { if (item.GroupUISetting != null) { result.GroupUISetting = new GroupUISettingDTO(); result.GroupUISetting.ID = item.GroupUISetting.ID; result.GroupUISetting.UIColumnsType = (Enum_UIColumnsType)item.GroupUISetting.UIColumnsType; result.GroupUISetting.Expander = item.GroupUISetting.Expander; result.GroupUISetting.IsExpanded = item.GroupUISetting.IsExpanded == true; result.GroupUISetting.InternalColumnsCount = item.GroupUISetting.InternalColumnsCount; result.GroupUISetting.UIRowsCount = Convert.ToInt16(item.GroupUISetting.UIRowsCount); } } else if (result.ObjectCategory == DatabaseObjectCategory.TabControl) { if (item.TabGroupUISetting != null) { result.TabGroupUISetting = new TabGroupUISettingDTO(); result.TabGroupUISetting.ID = item.TabGroupUISetting.ID; result.TabGroupUISetting.UIColumnsType = (Enum_UIColumnsType)item.TabGroupUISetting.UIColumnsType; result.TabGroupUISetting.Expander = item.TabGroupUISetting.Expander; result.TabGroupUISetting.IsExpanded = item.TabGroupUISetting.IsExpanded == true; result.TabGroupUISetting.UIRowsCount = Convert.ToInt16(item.TabGroupUISetting.UIRowsCount); } } else if (result.ObjectCategory == DatabaseObjectCategory.TabPage) { if (item.TabPageUISetting != null) { result.TabPageUISetting = new TabPageUISettingDTO(); result.TabPageUISetting.ID = item.TabPageUISetting.ID; result.TabPageUISetting.InternalColumnsCount = item.TabPageUISetting.InternalColumnsCount; } } else if (result.ObjectCategory == DatabaseObjectCategory.EmptySpace) { if (item.EmptySpaceUISetting != null) { result.EmptySpaceUISetting = new EmptySpaceUISettingDTO(); result.EmptySpaceUISetting.ID = item.EmptySpaceUISetting.ID; result.EmptySpaceUISetting.UIColumnsType = (Enum_UIColumnsType)item.EmptySpaceUISetting.UIColumnsType; result.EmptySpaceUISetting.ExpandToEnd = item.EmptySpaceUISetting.ExtendToEnd; } } result.ChildItems = new List <EntityUICompositionDTO>(); if (withChilds) { foreach (var citem in item.EntityUIComposition1) { result.ChildItems.Add(ToEntityUICompositionDTO(citem, withChilds, columnItems, relationshipItems)); } } return(result); }