8
8
using Amazon ;
9
9
using Amazon . DynamoDBv2 ;
10
10
using Amazon . DynamoDBv2 . DataModel ;
11
- using Amazon . EventBridge ;
12
11
using Amazon . Lambda . APIGatewayEvents ;
13
12
using Amazon . Lambda . Core ;
14
13
using Amazon . Util ;
18
17
using AWS . Lambda . Powertools . Tracing ;
19
18
using DynamoDBContextConfig = Amazon . DynamoDBv2 . DataModel . DynamoDBContextConfig ;
20
19
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
-
24
20
namespace Unicorn . Contracts . ContractService
25
21
{
26
22
public class UpdateContractFunction
@@ -138,14 +134,14 @@ private UpdateContractRequest ValidateEvent(APIGatewayProxyRequest apigProxyEven
138
134
{
139
135
try
140
136
{
141
- Console . WriteLine ( $ "Getting contract { propertyId } ") ;
137
+ Logger . LogInformation ( $ "Getting contract { propertyId } ") ;
142
138
var contract = await _dynamoDbContext . LoadAsync < Contract > ( propertyId ) . ConfigureAwait ( false ) ;
143
- Console . WriteLine ( $ "Found contact: { contract != null } ") ;
139
+ Logger . LogInformation ( $ "Found contact: { contract != null } ") ;
144
140
return contract ;
145
141
}
146
142
catch ( Exception e )
147
143
{
148
- Console . WriteLine ( $ "Error loading contract { propertyId } : { e . Message } ") ;
144
+ Logger . LogError ( $ "Error loading contract { propertyId } : { e . Message } ") ;
149
145
return null ;
150
146
}
151
147
}
@@ -160,12 +156,12 @@ private async Task UpdateContract(Contract contract)
160
156
{
161
157
try
162
158
{
163
- Console . WriteLine ( $ "Saving contract with id { contract . PropertyId } ") ;
159
+ Logger . LogInformation ( $ "Saving contract with id { contract . PropertyId } ") ;
164
160
await _dynamoDbContext . SaveAsync ( contract ) . ConfigureAwait ( false ) ;
165
161
}
166
162
catch ( AmazonDynamoDBException e )
167
163
{
168
- Console . WriteLine ( e ) ;
164
+ Logger . LogError ( e ) ;
169
165
throw ;
170
166
}
171
167
}
0 commit comments