Skip to content

Commit fd3986b

Browse files
committed
Fix the build
1 parent a032815 commit fd3986b

File tree

5 files changed

+40
-25
lines changed

5 files changed

+40
-25
lines changed

Tests/AwsLambdaFunction/AwsLambdaFunction.Api/DynAffiliatesFunctions.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using AwsLambdaFunction.Application.Interfaces;
1515
using AwsLambdaFunction.Domain.Common.Interfaces;
1616
using Intent.RoslynWeaver.Attributes;
17+
using Microsoft.Extensions.Logging;
1718

1819
[assembly: DefaultIntentManaged(Mode.Fully)]
1920
[assembly: IntentTemplate("Intent.Aws.Lambda.Functions.LambdaFunctionClassTemplate", Version = "1.0")]
@@ -22,16 +23,19 @@ namespace AwsLambdaFunction.Api
2223
{
2324
public class DynAffiliatesFunctions
2425
{
26+
private readonly ILogger<DynAffiliatesFunctions> _logger;
2527
private readonly IDynAffiliatesService _appService;
2628
private readonly IValidationService _validationService;
2729
private readonly IDynamoDBUnitOfWork _dynamoDBUnitOfWork;
2830
private readonly IUnitOfWork _unitOfWork;
2931

30-
public DynAffiliatesFunctions(IDynAffiliatesService appService,
32+
public DynAffiliatesFunctions(ILogger<DynAffiliatesFunctions> logger,
33+
IDynAffiliatesService appService,
3134
IValidationService validationService,
3235
IDynamoDBUnitOfWork dynamoDBUnitOfWork,
3336
IUnitOfWork unitOfWork)
3437
{
38+
_logger = logger;
3539
_appService = appService ?? throw new ArgumentNullException(nameof(appService));
3640
_validationService = validationService ?? throw new ArgumentNullException(nameof(validationService));
3741
_dynamoDBUnitOfWork = dynamoDBUnitOfWork ?? throw new ArgumentNullException(nameof(dynamoDBUnitOfWork));
@@ -59,7 +63,7 @@ public async Task<IHttpResult> CreateDynAffiliateAsync([FromBody] CreateDynAffil
5963

6064
await _dynamoDBUnitOfWork.SaveChangesAsync(cancellationToken);
6165
return HttpResults.Created($"/api/dyn-affiliates/{Uri.EscapeDataString(result.ToString())}", new JsonResponse<string>(result));
62-
});
66+
}, _logger);
6367
}
6468

6569
[LambdaFunction]
@@ -82,7 +86,7 @@ public async Task<IHttpResult> UpdateDynAffiliateAsync(string id, [FromBody] Upd
8286

8387
await _dynamoDBUnitOfWork.SaveChangesAsync(cancellationToken);
8488
return HttpResults.NewResult(HttpStatusCode.NoContent);
85-
});
89+
}, _logger);
8690
}
8791

8892
[LambdaFunction]
@@ -96,7 +100,7 @@ public async Task<IHttpResult> FindAffiliateByIdAsync(string id)
96100
var result = default(DynAffiliateDto);
97101
result = await _appService.FindAffiliateById(id, cancellationToken);
98102
return result == null ? HttpResults.NotFound() : HttpResults.Ok(result);
99-
});
103+
}, _logger);
100104
}
101105

102106
[LambdaFunction]
@@ -110,7 +114,7 @@ public async Task<IHttpResult> FindDynAffiliatesAsync()
110114
var result = default(List<DynAffiliateDto>);
111115
result = await _appService.FindDynAffiliates(cancellationToken);
112116
return HttpResults.Ok(result);
113-
});
117+
}, _logger);
114118
}
115119

116120
[LambdaFunction]
@@ -131,7 +135,7 @@ public async Task<IHttpResult> DeleteDynAffiliateAsync(string id)
131135

132136
await _dynamoDBUnitOfWork.SaveChangesAsync(cancellationToken);
133137
return HttpResults.Ok();
134-
});
138+
}, _logger);
135139
}
136140
}
137141
}

Tests/AwsLambdaFunction/AwsLambdaFunction.Api/DynClientsFunctions.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Intent.RoslynWeaver.Attributes;
1717
using MediatR;
1818
using Microsoft.Extensions.DependencyInjection;
19+
using Microsoft.Extensions.Logging;
1920

2021
[assembly: DefaultIntentManaged(Mode.Fully)]
2122
[assembly: IntentTemplate("Intent.Aws.Lambda.Functions.LambdaFunctionClassTemplate", Version = "1.0")]
@@ -24,10 +25,12 @@ namespace AwsLambdaFunction.Api
2425
{
2526
public class DynClientsFunctions
2627
{
28+
private readonly ILogger<DynClientsFunctions> _logger;
2729
private readonly ISender _mediator;
2830

29-
public DynClientsFunctions(ISender mediator)
31+
public DynClientsFunctions(ILogger<DynClientsFunctions> logger, ISender mediator)
3032
{
33+
_logger = logger;
3134
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
3235
}
3336

@@ -41,7 +44,7 @@ public async Task<IHttpResult> CreateDynClientAsync([FromBody] CreateDynClientCo
4144
{
4245
var result = await _mediator.Send(command, cancellationToken);
4346
return HttpResults.Created($"/api/dyn-clients/{Uri.EscapeDataString(result.ToString())}", new JsonResponse<string>(result));
44-
});
47+
}, _logger);
4548
}
4649

4750
[LambdaFunction]
@@ -54,7 +57,7 @@ public async Task<IHttpResult> DeleteDynClientAsync(string id)
5457
{
5558
await _mediator.Send(new DeleteDynClientCommand(id: id), cancellationToken);
5659
return HttpResults.Ok();
57-
});
60+
}, _logger);
5861
}
5962

6063
[LambdaFunction]
@@ -72,7 +75,7 @@ public async Task<IHttpResult> UpdateDynClientAsync(string id, [FromBody] Update
7275

7376
await _mediator.Send(command, cancellationToken);
7477
return HttpResults.NewResult(HttpStatusCode.NoContent);
75-
});
78+
}, _logger);
7679
}
7780

7881
[LambdaFunction]
@@ -85,7 +88,7 @@ public async Task<IHttpResult> GetDynClientByIdAsync(string id)
8588
{
8689
var result = await _mediator.Send(new GetDynClientByIdQuery(id: id), cancellationToken);
8790
return result == null ? HttpResults.NotFound() : HttpResults.Ok(result);
88-
});
91+
}, _logger);
8992
}
9093

9194
[LambdaFunction]
@@ -98,7 +101,7 @@ public async Task<IHttpResult> GetDynClientsAsync()
98101
{
99102
var result = await _mediator.Send(new GetDynClientsQuery(), cancellationToken);
100103
return HttpResults.Ok(result);
101-
});
104+
}, _logger);
102105
}
103106
}
104107
}

Tests/AwsLambdaFunction/AwsLambdaFunction.Api/EfAffiliatesFunctions.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using AwsLambdaFunction.Application.Interfaces;
1515
using AwsLambdaFunction.Domain.Common.Interfaces;
1616
using Intent.RoslynWeaver.Attributes;
17+
using Microsoft.Extensions.Logging;
1718

1819
[assembly: DefaultIntentManaged(Mode.Fully)]
1920
[assembly: IntentTemplate("Intent.Aws.Lambda.Functions.LambdaFunctionClassTemplate", Version = "1.0")]
@@ -22,16 +23,19 @@ namespace AwsLambdaFunction.Api
2223
{
2324
public class EfAffiliatesFunctions
2425
{
26+
private readonly ILogger<EfAffiliatesFunctions> _logger;
2527
private readonly IEfAffiliatesService _appService;
2628
private readonly IValidationService _validationService;
2729
private readonly IDynamoDBUnitOfWork _dynamoDBUnitOfWork;
2830
private readonly IUnitOfWork _unitOfWork;
2931

30-
public EfAffiliatesFunctions(IEfAffiliatesService appService,
32+
public EfAffiliatesFunctions(ILogger<EfAffiliatesFunctions> logger,
33+
IEfAffiliatesService appService,
3134
IValidationService validationService,
3235
IDynamoDBUnitOfWork dynamoDBUnitOfWork,
3336
IUnitOfWork unitOfWork)
3437
{
38+
_logger = logger;
3539
_appService = appService ?? throw new ArgumentNullException(nameof(appService));
3640
_validationService = validationService ?? throw new ArgumentNullException(nameof(validationService));
3741
_dynamoDBUnitOfWork = dynamoDBUnitOfWork ?? throw new ArgumentNullException(nameof(dynamoDBUnitOfWork));
@@ -59,7 +63,7 @@ public async Task<IHttpResult> CreateEfAffiliateAsync([FromBody] CreateEfAffilia
5963

6064
await _dynamoDBUnitOfWork.SaveChangesAsync(cancellationToken);
6165
return HttpResults.Created($"/api/ef-affiliates/{Uri.EscapeDataString(result.ToString())}", new JsonResponse<Guid>(result));
62-
});
66+
}, _logger);
6367
}
6468

6569
[LambdaFunction]
@@ -88,7 +92,7 @@ public async Task<IHttpResult> UpdateEfAffiliateAsync(string id, [FromBody] Upda
8892

8993
await _dynamoDBUnitOfWork.SaveChangesAsync(cancellationToken);
9094
return HttpResults.NewResult(HttpStatusCode.NoContent);
91-
});
95+
}, _logger);
9296
}
9397

9498
[LambdaFunction]
@@ -108,7 +112,7 @@ public async Task<IHttpResult> FindEfAffiliateByIdAsync(string id)
108112
var result = default(EfAffiliateDto);
109113
result = await _appService.FindEfAffiliateById(idGuid, cancellationToken);
110114
return result == null ? HttpResults.NotFound() : HttpResults.Ok(result);
111-
});
115+
}, _logger);
112116
}
113117

114118
[LambdaFunction]
@@ -122,7 +126,7 @@ public async Task<IHttpResult> FindEfAffiliatesAsync()
122126
var result = default(List<EfAffiliateDto>);
123127
result = await _appService.FindEfAffiliates(cancellationToken);
124128
return HttpResults.Ok(result);
125-
});
129+
}, _logger);
126130
}
127131

128132
[LambdaFunction]
@@ -150,7 +154,7 @@ public async Task<IHttpResult> DeleteEfAffiliateAsync(string id)
150154

151155
await _dynamoDBUnitOfWork.SaveChangesAsync(cancellationToken);
152156
return HttpResults.Ok();
153-
});
157+
}, _logger);
154158
}
155159
}
156160
}

Tests/AwsLambdaFunction/AwsLambdaFunction.Api/EfClientsFunctions.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Intent.RoslynWeaver.Attributes;
1717
using MediatR;
1818
using Microsoft.Extensions.DependencyInjection;
19+
using Microsoft.Extensions.Logging;
1920

2021
[assembly: DefaultIntentManaged(Mode.Fully)]
2122
[assembly: IntentTemplate("Intent.Aws.Lambda.Functions.LambdaFunctionClassTemplate", Version = "1.0")]
@@ -24,10 +25,12 @@ namespace AwsLambdaFunction.Api
2425
{
2526
public class EfClientsFunctions
2627
{
28+
private readonly ILogger<EfClientsFunctions> _logger;
2729
private readonly ISender _mediator;
2830

29-
public EfClientsFunctions(ISender mediator)
31+
public EfClientsFunctions(ILogger<EfClientsFunctions> logger, ISender mediator)
3032
{
33+
_logger = logger;
3134
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
3235
}
3336

@@ -41,7 +44,7 @@ public async Task<IHttpResult> CreateEfClientAsync([FromBody] CreateEfClientComm
4144
{
4245
var result = await _mediator.Send(command, cancellationToken);
4346
return HttpResults.Created($"/api/ef-clients/{Uri.EscapeDataString(result.ToString())}", new JsonResponse<Guid>(result));
44-
});
47+
}, _logger);
4548
}
4649

4750
[LambdaFunction]
@@ -61,7 +64,7 @@ public async Task<IHttpResult> DeleteEfClientAsync(string id)
6164

6265
await _mediator.Send(new DeleteEfClientCommand(idGuid), cancellationToken);
6366
return HttpResults.Ok();
64-
});
67+
}, _logger);
6568
}
6669

6770
[LambdaFunction]
@@ -86,7 +89,7 @@ public async Task<IHttpResult> UpdateEfClientAsync(string id, [FromBody] UpdateE
8689

8790
await _mediator.Send(command, cancellationToken);
8891
return HttpResults.NewResult(HttpStatusCode.NoContent);
89-
});
92+
}, _logger);
9093
}
9194

9295
[LambdaFunction]
@@ -106,7 +109,7 @@ public async Task<IHttpResult> GetEfClientByIdAsync(string id)
106109

107110
var result = await _mediator.Send(new GetEfClientByIdQuery(idGuid), cancellationToken);
108111
return result == null ? HttpResults.NotFound() : HttpResults.Ok(result);
109-
});
112+
}, _logger);
110113
}
111114

112115
[LambdaFunction]
@@ -119,7 +122,7 @@ public async Task<IHttpResult> GetEfClientsAsync()
119122
{
120123
var result = await _mediator.Send(new GetEfClientsQuery(), cancellationToken);
121124
return HttpResults.Ok(result);
122-
});
125+
}, _logger);
123126
}
124127
}
125128
}

Tests/AwsLambdaFunction/AwsLambdaFunction.Api/Helpers/ExceptionHandlerHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ namespace AwsLambdaFunction.Api.Helpers
1616
{
1717
public static class ExceptionHandlerHelper
1818
{
19-
public static async Task<IHttpResult> ExecuteAsync(Func<Task<IHttpResult>> operation)
19+
public static async Task<IHttpResult> ExecuteAsync(Func<Task<IHttpResult>> operation, ILogger logger)
2020
{
2121
try
2222
{
2323
return await operation();
2424
}
2525
catch (Exception ex)
2626
{
27+
logger.LogError(ex, "Unhandled exception occurred: {Message}", ex.Message);
2728
return HandleException(ex);
2829
}
2930
}

0 commit comments

Comments
 (0)