public static async Task <int?> GetExternalId(this IEntityMapService entityMapService, EntityType entityType, IdentifierEntity idEntity, IdentifierProperty property, int localId, int unitId) { var entityMaps = await entityMapService.SearchEntityMaps( new SearchQueryEntityMap( localId, entityType.ToString(), unitId, (int)ExternalEconomySystem.UniMicro, (int)Category.Timereg) { ExternalEntity = idEntity.ToString(), ExternalProperty = property.ToString() }); var value = entityMaps.FirstOrDefault()?.ExternalValue; return(int.TryParse(value, out int intValue) && intValue > 0 ? (int?)intValue : null); }
public void AddValidEntityMapEmployee(int unitId, int integrationId, int localId, int externalId = 1) { var entityMap = new EntityMap { IntegrationId = integrationId, EntityId = localId, Ignored = false, EntityName = EntityType.Employee.ToString(), ExternalEntity = IdentifierEntity.WorkRelation.ToString(), ExternalPropertyName = IdentifierProperty.Id.ToString(), ExternalValue = externalId.ToString(), }; A.CallTo(() => _entitymapService.SearchEntityMaps( A <SearchQueryEntityMap> .That.Matches(sq => sq.LocalId == entityMap.EntityId && sq.EntityName == entityMap.EntityName && sq.UnitId == unitId && sq.ExternalEntity == entityMap.ExternalEntity && sq.ExternalProperty == entityMap.ExternalPropertyName))) .Returns(new List <EntityMap> { entityMap }); }