diff --git a/Expedience.Api/Consumers/DutyCompletionResultConsumer.cs b/Expedience.Api/Consumers/DutyCompletionResultConsumer.cs index 6c89290..4a01b76 100644 --- a/Expedience.Api/Consumers/DutyCompletionResultConsumer.cs +++ b/Expedience.Api/Consumers/DutyCompletionResultConsumer.cs @@ -78,6 +78,9 @@ namespace Expedience.Api.Consumers } // Insert this territory if it does not exist + _logger.LogInformation("Checking if territory {territoryId} - {contentName} exists", + completionResult.TerritoryId, message.DutyInfo.ContentName); + var territory = dbContext.Territories.FirstOrDefault(t => t.TerritoryId == completionResult.TerritoryId); if (territory == null) { @@ -92,14 +95,17 @@ namespace Expedience.Api.Consumers Level = 0, }); } - else if (String.IsNullOrWhiteSpace(territory.ContentName)) + else { - _logger.LogInformation("Updating territory {territoryId} with content name {contentName} and place name {placeName}", - completionResult.TerritoryId, message.DutyInfo.ContentName, message.DutyInfo.PlaceName); - - // Update the place/content name if necessary - territory.ContentName = message.DutyInfo.ContentName; - territory.PlaceName = message.DutyInfo.PlaceName; + _logger.LogInformation("Territory with Id {territoryId} with name {contentName}", territory.TerritoryId, territory.ContentName); + if (String.IsNullOrWhiteSpace(territory.ContentName)) + { + _logger.LogInformation("Updating territory {territoryId} with content name {contentName} and place name {placeName}", + completionResult.TerritoryId, message.DutyInfo.ContentName, message.DutyInfo.PlaceName); + // Update the place/content name if necessary + territory.ContentName = message.DutyInfo.ContentName; + territory.PlaceName = message.DutyInfo.PlaceName; + } } await dbContext.SaveChangesAsync();