diff --git a/src/StreetNameRegistry.Projections.Integration/Converters/StreetNameMapper.cs b/src/StreetNameRegistry.Projections.Integration/Converters/StreetNameMapper.cs index 73ee068f7..bf778c29c 100644 --- a/src/StreetNameRegistry.Projections.Integration/Converters/StreetNameMapper.cs +++ b/src/StreetNameRegistry.Projections.Integration/Converters/StreetNameMapper.cs @@ -24,7 +24,7 @@ public static string Map(this StreetNameStatus status) } } - public static void UpdateNameByLanguage(this StreetNameVersion item, Language? language, string value) + public static void UpdateNameByLanguage(this StreetNameVersion item, Language? language, string? value) { switch (language) { @@ -46,7 +46,7 @@ public static void UpdateNameByLanguage(this StreetNameVersion item, Language? l } } - public static void UpdateHomonymAdditionByLanguage(this StreetNameVersion item, Language? language, string value) + public static void UpdateHomonymAdditionByLanguage(this StreetNameVersion item, Language? language, string? value) { switch (language) { diff --git a/src/StreetNameRegistry.Projections.Integration/StreetNameVersionProjections.cs b/src/StreetNameRegistry.Projections.Integration/StreetNameVersionProjections.cs index 20602800c..b52a6324d 100644 --- a/src/StreetNameRegistry.Projections.Integration/StreetNameVersionProjections.cs +++ b/src/StreetNameRegistry.Projections.Integration/StreetNameVersionProjections.cs @@ -71,7 +71,7 @@ await context.NewStreetNameVersion( await context.NewStreetNameVersion( message.Message.StreetNameId, message, - entity => { entity.UpdateNameByLanguage(message.Message.Language, string.Empty); }, + entity => { entity.UpdateNameByLanguage(message.Message.Language, null); }, ct); }); @@ -80,7 +80,7 @@ await context.NewStreetNameVersion( await context.NewStreetNameVersion( message.Message.StreetNameId, message, - entity => { entity.UpdateNameByLanguage(message.Message.Language, string.Empty); }, + entity => { entity.UpdateNameByLanguage(message.Message.Language, null); }, ct); }); @@ -107,7 +107,7 @@ await context.NewStreetNameVersion( await context.NewStreetNameVersion( message.Message.StreetNameId, message, - entity => { entity.UpdateHomonymAdditionByLanguage(message.Message.Language, string.Empty); }, + entity => { entity.UpdateHomonymAdditionByLanguage(message.Message.Language, null); }, ct); }); @@ -116,7 +116,7 @@ await context.NewStreetNameVersion( await context.NewStreetNameVersion( message.Message.StreetNameId, message, - entity => { entity.UpdateHomonymAdditionByLanguage(message.Message.Language, string.Empty); }, + entity => { entity.UpdateHomonymAdditionByLanguage(message.Message.Language, null); }, ct); }); @@ -143,10 +143,7 @@ await context.NewStreetNameVersion( await context.NewStreetNameVersion( message.Message.StreetNameId, message, - item => - { - item.IsRemoved = true; - }, + item => { item.IsRemoved = true; }, ct); }); @@ -267,16 +264,20 @@ await context.NewStreetNameVersion( When>(async (context, message, ct) => { - var streetNamePersistentLocalIds = await context.StreetNameVersions.Where(x => x.MunicipalityId == message.Message.MunicipalityId) - .Select(x => x.PersistentLocalId) - .ToListAsync(ct); - - foreach (var persistentLocalId in streetNamePersistentLocalIds) + var persistentLocalIds = context + .StreetNameVersions + .Local + .Where(s => + s.MunicipalityId == message.Message.MunicipalityId) + .Union(context.StreetNameVersions.Where(s => + s.MunicipalityId == message.Message.MunicipalityId)) + .Select(s => s.PersistentLocalId); + + foreach (var persistentLocalId in persistentLocalIds) { await context.NewStreetNameVersion(persistentLocalId, message, item => { item.NisCode = message.Message.NisCode; - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); } }); @@ -341,7 +342,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { item.Status = StreetNameStatus.Current; item.OsloStatus = StreetNameStatus.Current.Map(); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -351,7 +351,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { item.Status = StreetNameStatus.Proposed; item.OsloStatus = StreetNameStatus.Proposed.Map(); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -361,7 +360,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { item.Status = StreetNameStatus.Rejected; item.OsloStatus = StreetNameStatus.Rejected.Map(); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -371,7 +369,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { item.Status = StreetNameStatus.Proposed; item.OsloStatus = StreetNameStatus.Proposed.Map(); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -381,7 +378,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { item.Status = StreetNameStatus.Retired; item.OsloStatus = StreetNameStatus.Retired.Map(); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -391,7 +387,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { item.Status = StreetNameStatus.Retired; item.OsloStatus = StreetNameStatus.Retired.Map(); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -401,7 +396,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { item.Status = StreetNameStatus.Current; item.OsloStatus = StreetNameStatus.Current.Map(); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -411,7 +405,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { foreach (var (language, value) in message.Message.StreetNameNames) item.UpdateNameByLanguage(language, value); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -421,7 +414,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { foreach (var (language, value) in message.Message.StreetNameNames) item.UpdateNameByLanguage(language, value); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -431,7 +423,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i { foreach (var (language, value) in message.Message.HomonymAdditions) item.UpdateHomonymAdditionByLanguage(language, value); - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -460,8 +451,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i throw new ArgumentOutOfRangeException(); } } - - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); @@ -470,7 +459,6 @@ await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, i await context.NewStreetNameVersion(message.Message.PersistentLocalId, message, item => { item.IsRemoved = true; - item.VersionTimestamp = message.Message.Provenance.Timestamp; }, ct); }); }