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