public List <HierarchyEntity> GetEntityChild() { HierarchyEntity entity = EntityInstance; List <HierarchyEntity> result = null; if (entity != null) { result = entity.GetChild(); } return(result); }
public HierarchyEntity Set() { HierarchyEntity result = null; HierarchyRecord saveResult = null; var handler = GetHandler(); if (handler != null) { saveResult = handler.Save(); } if (saveResult != null) { result = new HierarchyEntity(saveResult); } return(result); }
private static List <HierarchyEntity> RecordListToEntitiesList(List <HierarchyRecord> recordList) { List <HierarchyEntity> child = null; if (recordList != null) { foreach (var record in recordList) { var entity = new HierarchyEntity(record); if (child == null) { child = new List <HierarchyEntity>(); } child.Add(entity); } } return(child); }
public List <HierarchyEntity> Get(long?hierarchyId = null, long?parent = null, string name = null) { List <HierarchyEntity> result = null; var handler = Handler; if (handler != null) { if (handler.Pattern != null) { handler.Pattern.Parent = parent; handler.Pattern.Id = hierarchyId; handler.Pattern.Name = name; } } List <HierarchyRecord> records = null; if (handler != null) { records = handler.Get(); } if (records != null) { foreach (var record in records) { if (record != null) { var resultRecord = new HierarchyEntity(record); if (result == null) { result = new List <HierarchyEntity>(); } result.Add(resultRecord); } } } return(result); }
public bool Move(HierarchyEntity source, HierarchyEntity target) { var result = false; if (target != null && source != null) { var targetId = target.Id; var isSourceContainTarget = true; if (source.Id != targetId) { var childList = GetEntityChild(); if (childList != null) { isSourceContainTarget = childList.Where(x => x != null).Any // ReSharper disable SimplifyConditionalTernaryExpression (x => x.Id.HasValue ? (x.Id.Value == targetId) : false); // ReSharper restore SimplifyConditionalTernaryExpression } else { isSourceContainTarget = false; } } if (!isSourceContainTarget) { source.Parent = targetId; source = Set(); if (source != null) { result = source.Id.HasValue; } } } return(result); }
public Hierarchy() { _handler = new DataAccess.Hierarchy(); EntityInstance = new HierarchyEntity(); }
public static List <HierarchyEntity> GetAllHierarchies() { var result = HierarchyEntity.GetAllHierarchies(); return(result); }