public void ReturnNullIfEntityNull()
        {
            IMdmEntity value = null;

            var candidate = value.SystemIdentifier();

            Assert.IsNull(candidate);
        }
Esempio n. 2
0
        public void ReturnNullIfEntityNull()
        {
            IMdmEntity entity = null;

            var candidate = entity.PrimaryIdentifier();

            Assert.IsNull(candidate);
        }
Esempio n. 3
0
        /// <summary>
        /// Check whether an MDM entity has an identifier.
        /// </summary>
        /// <param name="entity">Entity to check</param>
        /// <param name="value">Identifier to use</param>
        /// <returns>true if the identifier is equal to any of the entities identifiers, otherwise false.</returns>
        public static bool HasIdentifier(this IMdmEntity entity, MdmId value)
        {
            if (entity == null || value == null)
            {
                return(false);
            }

            return(entity.Identifiers.Any(id => id.Equals(value)));
        }
        public static int?MdmId(this IMdmEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            return
                (entity.Identifiers.Where(id => id.IsMdmId)
                 .Select(nexusId => nexusId.Identifier == null ? null : new int?(int.Parse(nexusId.Identifier)))
                 .FirstOrDefault());
        }
Esempio n. 5
0
 /// <summary>
 /// Gets a MDM Id for a system
 /// </summary>
 /// <param name="entity">Entity to use</param>
 /// <param name="systemName">System to check</param>
 /// <returns>First identifier found for the system or null if not found.</returns>
 public static MdmId SystemId(this IMdmEntity entity, string systemName = "Nexus")
 {
     return(entity == null ? null : entity.Identifiers.SystemId(systemName));
 }
Esempio n. 6
0
 /// <summary>
 /// Determine the primary identifier for a MDM entity.
 /// </summary>
 /// <param name="entity">Entity to use</param>
 /// <param name="systemName">System to use if no SourceSystemOriginated identifier exists</param>
 /// <returns>The identifier with SourceSystemOriginated, or the one identified by systemName or the first identifier</returns>
 public static MdmId PrimaryIdentifier(this IMdmEntity entity, string systemName = null)
 {
     return(entity == null ? null : entity.Identifiers.PrimaryIdentifier(systemName));
 }
Esempio n. 7
0
        /// <summary>
        /// Get the Nexus key for a MDM entity
        /// </summary>
        /// <param name="entity">Entity to use</param>
        /// <returns></returns>
        public static string ToMdmKeyString(this IMdmEntity entity)
        {
            var nexusId = entity.ToMdmId();

            return(nexusId.ToIdentifier());
        }
Esempio n. 8
0
        /// <summary>
        /// Get the Nexus MDM key for a MDM entity
        /// </summary>
        /// <param name="entity">Entity to use</param>
        /// <param name="defaultValue"></param>
        /// <returns>Value of the entity's MDM Id if present, default value (0) otherwise.</returns>
        public static int ToMdmKey(this IMdmEntity entity, int defaultValue = 0)
        {
            var nexusId = entity.ToMdmId();

            return(nexusId.ToKey(defaultValue));
        }
Esempio n. 9
0
 /// <summary>
 /// Locate the Nexus MDM identifier for a MDM entity.
 /// </summary>
 /// <param name="entity">Entity to use</param>
 /// <returns></returns>
 public static MdmId ToMdmId(this IMdmEntity entity)
 {
     return(entity == null ? null : entity.Identifiers.FirstOrDefault(id => id.IsMdmId));
 }
Esempio n. 10
0
        /// <summary>
        /// Gets an identifier value for a system
        /// </summary>
        /// <param name="entity">Entity to use</param>
        /// <param name="systemName">System to check</param>
        /// <returns>First identifier found for the system or <see cref="string.Empty"/> if not found.</returns>
        public static string SystemIdentifier(this IMdmEntity entity, string systemName = "Nexus")
        {
            var id = entity.SystemId(systemName);

            return(id == null ? null : id.Identifier);
        }
        /// <summary>
        /// Adds a search clause to the current criteria based on the MDM <see cref="EntityId" />
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="searchField"></param>
        /// <param name="entity"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static SearchCriteria AddMdmIdCriteria(this SearchCriteria criteria, string searchField, IMdmEntity entity, SearchCondition condition = SearchCondition.Equals)
        {
            var nexusId = entity.ToMdmKeyString();

            criteria.AddCriteria(searchField, condition, nexusId, true);

            return(criteria);
        }
Esempio n. 12
0
        public static T Create <T>() where T : IMdmEntity
        {
            IMdmEntity value = Create(typeof(T).Name);

            return((T)value);
        }