/// <summary> /// Get all CompetencyFrameworks for the provided entity /// The returned entities are just the base /// </summary> /// <param name="parentUid"></param> /// <returns></returnsThisEntity public static List <WPM.CompetencyFramework> GetAll(Guid parentUid) { var list = new List <WPM.CompetencyFramework>(); var entity = new WPM.CompetencyFramework(); Entity parent = EntityManager.GetEntity(parentUid); LoggingHelper.DoTrace(7, string.Format("EntityCompetencyFrameworks_GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parentUid, parent.Id, parent.EntityTypeId)); try { using (var context = new EntityContext()) { List <DBEntity> results = context.Entity_CompetencyFramework .Where(s => s.EntityId == parent.Id) .OrderBy(s => s.CompetencyFramework.Name) .ToList(); if (results != null && results.Count > 0) { foreach (DBEntity item in results) { entity = new WPM.CompetencyFramework(); if (item.CompetencyFramework != null && item.CompetencyFramework.EntityStateId > 1) { CompetencyFrameworkManager.MapFromDB(item.CompetencyFramework, entity); list.Add(entity); } } } return(list); } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + string.Format(".EntityCompetencyFrameworks_GetAll. Guid: {0}, parentType: {1} ({2}), ", parentUid, parent.EntityType, parent.EntityBaseId)); } return(list); }
public static ThisEntity Get(int parentId, int CompetencyFrameworkId) { ThisEntity entity = new ThisEntity(); if (parentId < 1 || CompetencyFrameworkId < 1) { return(entity); } try { using (var context = new EntityContext()) { var from = context.Entity_CompetencyFramework .SingleOrDefault(s => s.CompetencyFrameworkId == CompetencyFrameworkId && s.EntityId == parentId); if (from != null && from.Id > 0) { entity.Id = from.Id; entity.CompetencyFrameworkId = from.CompetencyFrameworkId; entity.EntityId = from.EntityId; entity.ProfileSummary = from.CompetencyFramework.Name; //to.Credential = from.Credential; entity.CompetencyFramework = new WPM.CompetencyFramework(); CompetencyFrameworkManager.MapFromDB(from.CompetencyFramework, entity.CompetencyFramework); if (IsValidDate(from.Created)) { entity.Created = ( DateTime )from.Created; } } } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".Get"); } return(entity); } //