From 6105062500fef2495928bb1d7fd1778813112177 Mon Sep 17 00:00:00 2001 From: ilitirit Date: Wed, 7 Aug 2024 19:02:20 +0200 Subject: [PATCH] Add more logging --- .../Consumers/DutyCompletionResultConsumer.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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();