public void ReturnNullIfEntityNull() { IMdmEntity value = null; var candidate = value.SystemIdentifier(); Assert.IsNull(candidate); }
public void ReturnNullIfEntityNull() { IMdmEntity entity = null; var candidate = entity.PrimaryIdentifier(); Assert.IsNull(candidate); }
/// <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()); }
/// <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)); }
/// <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)); }
/// <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()); }
/// <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)); }
/// <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)); }
/// <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); }
public static T Create <T>() where T : IMdmEntity { IMdmEntity value = Create(typeof(T).Name); return((T)value); }