/// <summary>
        /// Get all learning opportunties for the parent
        /// Uses the parent Guid to retrieve the related Entity, then uses the EntityId to retrieve the child objects.
        /// </summary>
        /// <param name="parentUid"></param>
        /// <param name="forProfilesList"></param>
        /// <returns></returns>
        public static List <ThisEntity> LearningOpps_GetAll(Guid parentUid,
                                                            bool forProfilesList,
                                                            bool isForCredentialDetails = false, int relationshipTypeId = 1)
        {
            List <ThisEntity> list   = new List <ThisEntity>();
            ThisEntity        entity = new ThisEntity();

            Entity parent = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                return(list);
            }
            //TODO - this was left over from the publisher, needs to be cleaned up
            bool includingProperties = isForCredentialDetails;
            bool includingProfiles   = false;

            if (isForCredentialDetails)
            {
                includingProperties = true;
                includingProfiles   = true;
            }
            LoggingHelper.DoTrace(7, string.Format("Entity_LearningOpps_GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parentUid, parent.Id, parent.EntityTypeId));
            try
            {
                using (var context = new EntityContext())
                {
                    List <DBEntity> results = context.Entity_LearningOpportunity
                                              .Where(s => s.EntityId == parent.Id && s.RelationshipTypeId == relationshipTypeId)
                                              .OrderBy(s => s.LearningOpportunity.Name)
                                              .ToList();

                    if (results != null && results.Count > 0)
                    {
                        foreach (DBEntity item in results)
                        {
                            entity = new ThisEntity();
                            if (item.LearningOpportunity != null && item.LearningOpportunity.EntityStateId > 1)
                            {
                                if (forProfilesList || isForCredentialDetails)
                                {
                                    LearningOpportunityManager.MapFromDB_Basic(item.LearningOpportunity, entity,
                                                                               true);

                                    if (isForCredentialDetails)
                                    {
                                        entity.EstimatedDuration = DurationProfileManager.GetAll(entity.RowId);
                                        LearningOpportunityManager.MapFromDB_HasPart(entity, false);
                                        LearningOpportunityManager.MapFromDB_Competencies(entity);
                                    }
                                    list.Add(entity);
                                }
                                else
                                {
                                    if (CacheManager.IsLearningOpportunityAvailableFromCache(item.LearningOpportunityId, ref entity))
                                    {
                                        list.Add(entity);
                                    }
                                    else
                                    {
                                        //TODO - is this section used??
                                        //to determine minimum needed for a or detail page
                                        LearningOpportunityManager.MapFromDB(item.LearningOpportunity, entity,
                                                                             includingProperties,
                                                                             includingProfiles,
                                                                             false //includeWhereUsed
                                                                             );
                                        list.Add(entity);
                                        if (entity.HasPart.Count > 0)
                                        {
                                            CacheManager.AddLearningOpportunityToCache(entity);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    return(list);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + string.Format(".LearningOpps_GetAll. Guid: {0}, parentType: {1} ({2}), ", parentUid, parent.EntityType, parent.EntityBaseId));
            }
            return(list);
        }
        /// <summary>
        /// Get all learning opportunties for the parent
        /// Uses the parent Guid to retrieve the related Entity, then uses the EntityId to retrieve the child objects.
        /// </summary>
        /// <param name="parentUid"></param>
        /// <param name="forProfilesList"></param>
        /// <returns></returns>
        public static List <ThisEntity> LearningOpps_GetAll(Guid parentUid,
                                                            bool forProfilesList,
                                                            bool isForCredentialDetails = false)
        {
            List <ThisEntity> list   = new List <ThisEntity>();
            ThisEntity        entity = new ThisEntity();

            Entity parent = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                return(list);
            }
            //TODO - this was left over from the publisher, needs to be cleaned up
            bool includingProperties = isForCredentialDetails;
            bool includingProfiles   = false;

            if (isForCredentialDetails)
            {
                includingProperties = true;
                includingProfiles   = true;
            }
            LoggingHelper.DoTrace(7, string.Format("Entity_LearningOpps_GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parentUid, parent.Id, parent.EntityTypeId));
            try
            {
                using (var context = new EntityContext())
                {
                    List <DBEntity> results = context.Entity_LearningOpportunity
                                              .Where(s => s.EntityId == parent.Id)
                                              .OrderBy(s => s.LearningOpportunity.Name)
                                              .ToList();

                    if (results != null && results.Count > 0)
                    {
                        foreach (DBEntity item in results)
                        {
                            entity = new ThisEntity();
                            if (item.LearningOpportunity != null && item.LearningOpportunity.EntityStateId > 1)
                            {
                                if (forProfilesList || isForCredentialDetails)
                                {
                                    LearningOpportunityManager.MapFromDB_Basic(item.LearningOpportunity, entity,
                                                                               true);

                                    //entity.Id = item.LearningOpportunityId;
                                    //                           entity.RowId = item.LearningOpportunity.RowId;

                                    //                           entity.Name = item.LearningOpportunity.Name;
                                    //                           entity.Description = item.LearningOpportunity.Description == null ? "" : item.LearningOpportunity.Description;
                                    //entity.EntityStateId = ( int )( item.LearningOpportunity.EntityStateId ?? 1 );
                                    //entity.SubjectWebpage = item.LearningOpportunity.SubjectWebpage;
                                    //                           entity.CTID = item.LearningOpportunity.CTID;
                                    //also get costs - really only need the profile list view
                                    //entity.EstimatedCost = CostProfileManager.GetAllForList( entity.RowId );
                                    //entity.CommonCosts = Entity_CommonCostManager.GetAll( entity.RowId );
                                    //get durations - need this for search and compare
                                    //entity.EstimatedDuration = DurationProfileManager.GetAll( entity.RowId );
                                    if (isForCredentialDetails)
                                    {
                                        entity.EstimatedDuration = DurationProfileManager.GetAll(entity.RowId);
                                        LearningOpportunityManager.MapFromDB_HasPart(entity, false);
                                        LearningOpportunityManager.MapFromDB_Competencies(entity);
                                    }
                                    list.Add(entity);
                                }
                                else
                                {
                                    if (CacheManager.IsLearningOpportunityAvailableFromCache(item.LearningOpportunityId, ref entity))
                                    {
                                        list.Add(entity);
                                    }
                                    else
                                    {
                                        //TODO - is this section used??
                                        //to determine minimum needed for a or detail page
                                        LearningOpportunityManager.MapFromDB(item.LearningOpportunity, entity,
                                                                             includingProperties,
                                                                             includingProfiles,
                                                                             false //includeWhereUsed
                                                                             );
                                        list.Add(entity);
                                        if (entity.HasPart.Count > 0)
                                        {
                                            CacheManager.AddLearningOpportunityToCache(entity);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    return(list);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".LearningOpps_GetAll");
            }
            return(list);
        }