} // public static List <Pathway> GetPathwayForComponent(int pathwayComponentId, int componentRelationshipTypeId) { /* * */ var entity = new Pathway(); var list = new List <Pathway>(); if (pathwayComponentId < 1 || componentRelationshipTypeId < 1) { return(list); } try { using (var context = new EntityContext()) { //there should be only one pathway-component for the passed relationship - typically ispartof List <DBEntity> results = context.Entity_HasPathwayComponent .Where(s => s.PathwayComponentId == pathwayComponentId && s.ComponentRelationshipTypeId == componentRelationshipTypeId && s.Entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY) .OrderBy(s => s.ComponentRelationshipTypeId) .ThenBy(s => s.Entity.EntityBaseName) // .ToList(); if (results != null && results.Count > 0) { foreach (var from in results) { if (from != null && from.Id > 0) { if (from.Entity != null && from.Entity.EntityBaseId != null) { //is basic enough? entity = PathwayManager.GetBasic(( int )from.Entity.EntityBaseId); } list.Add(entity); } } } } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".GetPathwayForComponent"); } return(list); } //
public bool UpdateParts(ThisEntity entity, ref SaveStatus status) { bool isAllValid = true; Entity_AgentRelationshipManager mgr = new Entity_AgentRelationshipManager(); Entity relatedEntity = EntityManager.GetEntity(entity.RowId); if (relatedEntity == null || relatedEntity.Id == 0) { status.AddError(thisClassName + " - Error - the parent entity was not found."); return(false); } mgr.DeleteAll(relatedEntity, ref status); mgr.SaveList(relatedEntity.Id, Entity_AgentRelationshipManager.ROLE_TYPE_OFFERED_BY, entity.OfferedBy, ref status); mgr.SaveList(relatedEntity.Id, Entity_AgentRelationshipManager.ROLE_TYPE_OWNER, entity.OwnedBy, ref status); var epmgr = new Entity_PathwayManager(); //handle pathways - using replace //actually just use typical pattern of delete all and then add //could be extreme //epmgr.DeleteAll( parent.EntityUid, ref status ); var list = new List <int>(); //check if we should get the list of ids easier foreach (var item in entity.HasPathwayList) { var p = PathwayManager.GetBasic(item); if (p != null && p.Id > 0) { list.Add(p.Id); } else { //?? status.AddError(thisClassName + string.Format(" - Error - the pathway using Guid: {0} entity was not found.", item.ToString())); } } if (!new Entity_PathwayManager().Replace(entity.RowId, 1, list, ref status)) { isAllValid = false; } return(isAllValid); }
public static ThisEntity GetBasic(int id) { ThisEntity entity = EntityMgr.GetBasic(id); return(entity); }