/// <summary> /// Format a summary of the HoldersProfile for use in search and gray boxes /// </summary> /// <param name="parentUid"></param> /// <returns></returns> public static string GetSummary(Guid parentUid) { var list = new List <HoldersProfile>(); var entity = new HoldersProfile(); Entity parent = EntityManager.GetEntity(parentUid); LoggingHelper.DoTrace(7, string.Format(thisClassName + ".GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parentUid, parent.Id, parent.EntityTypeId)); var summary = ""; var lineBreak = ""; try { using (var context = new EntityContext()) { List <DBEntity> results = context.Entity_HoldersProfile .Where(s => s.EntityId == parent.Id) .OrderBy(s => s.Created) .ToList(); if (results != null && results.Count > 0) { foreach (DBEntity item in results) { entity = new HoldersProfile(); if (item.HoldersProfile != null && item.HoldersProfile.EntityStateId > 1) { if (!string.IsNullOrWhiteSpace(item.HoldersProfile.Name)) { summary = item.HoldersProfile.Name + lineBreak; } else if (!string.IsNullOrWhiteSpace(item.HoldersProfile.Description)) { summary = item.HoldersProfile.Description.Length < 200 ? item.HoldersProfile.Description : item.HoldersProfile.Description.Substring(0, 200) + " ... " + lineBreak; } else { } if (item.HoldersProfile.NumberAwarded > 0) { summary += string.Format(" Number awarded: {0}", item.HoldersProfile.NumberAwarded); } } lineBreak = "<\br>"; } } return(summary); } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".GetSummary"); } return(summary); }
/// <summary> /// Get all HoldersProfile for the provided entity /// The returned entities are just the base /// </summary> /// <param name="parentUid"></param> /// <returns></returnsThisEntity public static List <HoldersProfile> GetAll(Entity parent, bool includingParts = true) { var list = new List <HoldersProfile>(); var entity = new HoldersProfile(); //Entity parent = EntityManager.GetEntity( parentUid ); LoggingHelper.DoTrace(7, string.Format(thisClassName + ".GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parent.EntityUid, parent.Id, parent.EntityTypeId)); try { using (var context = new EntityContext()) { List <DBEntity> results = context.Entity_HoldersProfile .Where(s => s.EntityId == parent.Id) .OrderBy(s => s.Created) .ToList(); if (results != null && results.Count > 0) { foreach (DBEntity item in results) { entity = new HoldersProfile(); //need to distinguish between on a detail page for conditions and Holders detail //would usually only want basics here?? //17-05-26 mp- change to MapFromDB_Basic if (item.HoldersProfile != null && item.HoldersProfile.EntityStateId > 1) { HoldersProfileManager.MapFromDB(item.HoldersProfile, entity, includingParts); list.Add(entity); } } } return(list); } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".GetAll"); } return(list); }