Skip to content

Commit 6dc0223

Browse files
committed
fix: minor changes to Contracts
1 parent cf6ff62 commit 6dc0223

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Unicorn.Contracts/ContractsService/CreateContractFunction.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ private async Task CreateContract(Contract contract)
196196
{
197197
Logger.LogInformation($"Saving contract for Property ID: {contract.PropertyId}");
198198
await _dynamoDbContext.SaveAsync(contract);
199+
200+
// Add custom metric for "New Contracts"
201+
Metrics.AddMetric("NewContracts", 1, MetricUnit.Count, MetricResolution.Standard);
199202
}
200203
catch (Exception e)
201204
{

Unicorn.Contracts/ContractsService/UpdateContractFunction.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Amazon;
99
using Amazon.DynamoDBv2;
1010
using Amazon.DynamoDBv2.DataModel;
11-
using Amazon.EventBridge;
1211
using Amazon.Lambda.APIGatewayEvents;
1312
using Amazon.Lambda.Core;
1413
using Amazon.Util;
@@ -18,9 +17,6 @@
1817
using AWS.Lambda.Powertools.Tracing;
1918
using DynamoDBContextConfig = Amazon.DynamoDBv2.DataModel.DynamoDBContextConfig;
2019

21-
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
22-
// [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
23-
2420
namespace Unicorn.Contracts.ContractService
2521
{
2622
public class UpdateContractFunction
@@ -138,14 +134,14 @@ private UpdateContractRequest ValidateEvent(APIGatewayProxyRequest apigProxyEven
138134
{
139135
try
140136
{
141-
Console.WriteLine($"Getting contract {propertyId}");
137+
Logger.LogInformation($"Getting contract {propertyId}");
142138
var contract = await _dynamoDbContext.LoadAsync<Contract>(propertyId).ConfigureAwait(false);
143-
Console.WriteLine($"Found contact: {contract != null}");
139+
Logger.LogInformation($"Found contact: {contract != null}");
144140
return contract;
145141
}
146142
catch (Exception e)
147143
{
148-
Console.WriteLine($"Error loading contract {propertyId}: {e.Message}");
144+
Logger.LogError($"Error loading contract {propertyId}: {e.Message}");
149145
return null;
150146
}
151147
}
@@ -160,12 +156,12 @@ private async Task UpdateContract(Contract contract)
160156
{
161157
try
162158
{
163-
Console.WriteLine($"Saving contract with id {contract.PropertyId}");
159+
Logger.LogInformation($"Saving contract with id {contract.PropertyId}");
164160
await _dynamoDbContext.SaveAsync(contract).ConfigureAwait(false);
165161
}
166162
catch (AmazonDynamoDBException e)
167163
{
168-
Console.WriteLine(e);
164+
Logger.LogError(e);
169165
throw;
170166
}
171167
}

0 commit comments

Comments
 (0)