コード例 #1
0
        /// <summary>
        /// Get all EmploymentOutcomeProfile for the provided entity
        /// The returned entities are just the base
        /// </summary>
        /// <param name="parentUid"></param>
        /// <returns></returnsThisEntity
        public static List <EmploymentOutcomeProfile> GetAll(Entity parent, bool includingParts = true)
        {
            var list   = new List <EmploymentOutcomeProfile>();
            var entity = new EmploymentOutcomeProfile();

            //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_EmploymentOutcomeProfile
                                              .Where(s => s.EntityId == parent.Id)
                                              .OrderBy(s => s.Created)
                                              .ToList();

                    if (results != null && results.Count > 0)
                    {
                        foreach (DBEntity item in results)
                        {
                            entity = new EmploymentOutcomeProfile();

                            //need to distinguish between on a detail page for conditions and EmploymentOutcomeProfile detail
                            //would usually only want basics here??
                            //17-05-26 mp- change to MapFromDB_Basic
                            if (item.EmploymentOutcomeProfile != null && item.EmploymentOutcomeProfile.EntityStateId > 1)
                            {
                                EmploymentOutcomeProfileManager.MapFromDB(item.EmploymentOutcomeProfile, entity, includingParts);
                                list.Add(entity);
                            }
                        }
                    }
                    return(list);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".GetAll");
            }
            return(list);
        }
コード例 #2
0
        /// <summary>
        /// Format a summary of the EmploymentOutcomeProfile for use in search and gray boxes
        /// </summary>
        /// <param name="parentUid"></param>
        /// <returns></returns>
        public static string GetSummary(Guid parentUid)
        {
            var list   = new List <EmploymentOutcomeProfile>();
            var entity = new EmploymentOutcomeProfile();

            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_EmploymentOutcomeProfile
                                              .Where(s => s.EntityId == parent.Id)
                                              .OrderBy(s => s.Created)
                                              .ToList();

                    if (results != null && results.Count > 0)
                    {
                        foreach (DBEntity item in results)
                        {
                            entity = new EmploymentOutcomeProfile();
                            if (item.EmploymentOutcomeProfile != null && item.EmploymentOutcomeProfile.EntityStateId > 1)
                            {
                                if (!string.IsNullOrWhiteSpace(item.EmploymentOutcomeProfile.Name))
                                {
                                    summary = item.EmploymentOutcomeProfile.Name + lineBreak;
                                }
                                else if (!string.IsNullOrWhiteSpace(item.EmploymentOutcomeProfile.Description))
                                {
                                    summary = item.EmploymentOutcomeProfile.Description.Length < 200 ? item.EmploymentOutcomeProfile.Description : item.EmploymentOutcomeProfile.Description.Substring(0, 200) + "  ... " + lineBreak;
                                }
                                else
                                {
                                }
                                if (item.EmploymentOutcomeProfile.JobsObtainedJson != null)
                                {
                                    var jp = JsonConvert.DeserializeObject <EmploymentOutcomeProfileProperties>(item.EmploymentOutcomeProfile.JobsObtainedJson);
                                    if (jp != null)
                                    {
                                        //unpack JobsObtainedList
                                        var jobsObtained = jp.JobsObtainedList;
                                        var joSummary    = jobsObtained[0].Summary();
                                        //need a helper for display
                                        if (!string.IsNullOrWhiteSpace(joSummary))
                                        {
                                            summary += string.Format(" Jobs Obtained: {0}", joSummary);
                                        }
                                    }
                                }
                            }
                            lineBreak = "<\br>";
                        }
                    }
                    return(summary);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".GetSummary");
            }
            return(summary);
        }