Esempio n. 1
0
        /// <summary>
        /// Get a basic PathwaySet by CTID
        /// </summary>
        /// <param name="ctid"></param>
        /// <returns></returns>
        public static ThisEntity GetByCtid(string ctid)
        {
            PathwaySet entity = new PathwaySet();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }

            using (var context = new EntityContext())
            {
                context.Configuration.LazyLoadingEnabled = false;
                EM.PathwaySet item = context.PathwaySet
                                     .FirstOrDefault(s => s.CTID.ToLower() == ctid.ToLower() &&
                                                     s.EntityStateId > 1
                                                     );

                if (item != null && item.Id > 0)
                {
                    MapFromDB(item, entity);
                }
            }

            return(entity);
        }
Esempio n. 2
0
        private bool ValidateProfile(PathwaySet profile, ref SaveStatus status, bool validatingUrls = true)
        {
            status.HasSectionErrors = false;

            if (string.IsNullOrWhiteSpace(profile.Name))
            {
                status.AddError("Error: A PathwaySet Name is required.");
            }
            if (!IsGuidValid(profile.OwningAgentUid))
            {
                //first determine if this is populated in edit mode
                status.AddError("An owning organization must be provided.");
            }

            if (string.IsNullOrWhiteSpace(profile.Description))
            {
                status.AddWarning("A PathwaySet Description must be entered");
            }
            if (string.IsNullOrWhiteSpace(profile.SubjectWebpage))
            {
                status.AddError("A Subject Webpage name must be entered");
            }

            else if (validatingUrls && !IsUrlValid(profile.SubjectWebpage, ref commonStatusMessage))
            {
                status.AddError("The PathwaySet Subject Webpage is invalid. " + commonStatusMessage);
            }


            return(status.WasSectionValid);
        }
        public static PathwaySet PathwaySetGetByCtid(string ctid)
        {
            var entity = new PathwaySet();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }

            return(PathwaySetManager.GetByCtid(ctid));
        }
        public bool PathwaySetImport(PathwaySet entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //need to force caching here
                //var detail = GetDetail( entity.Id );
            }
            bool          isValid  = new PathwaySetManager().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //no caching at this time
                    //new CacheManager().PopulateEntityRelatedCaches( entity.RowId );
                    //update Elastic
                    if (UtilityManager.GetAppKeyValue("usingElasticPathwaySearch", false))
                    {
                        ElasticHelper.Pathway_UpdateIndex(entity.Id);
                    }
                    else
                    {
                        new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_PATHWAY_SET, entity.Id, 1, ref messages);
                        if (messages.Count > 0)
                        {
                            status.AddWarningRange(messages);
                        }
                    }
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_PATHWAY_SET, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }