File tree Expand file tree Collapse file tree 3 files changed +23
-10
lines changed
CarvedRock.Api/Controllers Expand file tree Collapse file tree 3 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -8,16 +8,19 @@ namespace CarvedRock.Api.Controllers;
88[ Route ( "[controller]" ) ]
99public class ProductController : ControllerBase
1010{
11+ private readonly ILogger < ProductController > _logger ;
1112 private readonly IProductLogic _productLogic ;
1213
13- public ProductController ( IProductLogic productLogic )
14+ public ProductController ( ILogger < ProductController > logger , IProductLogic productLogic )
1415 {
16+ _logger = logger ;
1517 _productLogic = productLogic ;
1618 }
1719
1820 [ HttpGet ]
1921 public async Task < IEnumerable < ProductModel > > Get ( string category = "all" )
2022 {
23+ _logger . LogInformation ( "Getting products in API for {category}" , category ) ;
2124 return await _productLogic . GetProductsForCategory ( category ) ;
2225 }
2326}
Original file line number Diff line number Diff line change 1- <Project Sdk =" Microsoft.NET.Sdk" >
2-
3- <PropertyGroup >
4- <TargetFramework >net6.0</TargetFramework >
5- <ImplicitUsings >enable</ImplicitUsings >
6- <Nullable >enable</Nullable >
7- </PropertyGroup >
8-
9- </Project >
1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <PropertyGroup >
3+ <TargetFramework >net6.0</TargetFramework >
4+ <ImplicitUsings >enable</ImplicitUsings >
5+ <Nullable >enable</Nullable >
6+ </PropertyGroup >
7+ <ItemGroup >
8+ <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 6.0.0" />
9+ </ItemGroup >
10+ </Project >
Original file line number Diff line number Diff line change 11using CarvedRock . Domain . Models ;
2+ using Microsoft . Extensions . Logging ;
23
34namespace CarvedRock . Domain ;
45
56public class ProductLogic : IProductLogic
67{
8+ private readonly ILogger < ProductLogic > _logger ;
9+
10+ public ProductLogic ( ILogger < ProductLogic > logger )
11+ {
12+ _logger = logger ;
13+ }
714 public Task < IEnumerable < ProductModel > > GetProductsForCategory ( string category )
815 {
16+ _logger . LogInformation ( "Getting products in logic for {category}" , category ) ;
17+
918 return Task . FromResult ( GetAllProducts ( ) . Where ( a =>
1019 string . Equals ( "all" , category , StringComparison . InvariantCultureIgnoreCase ) ||
1120 string . Equals ( category , a . Category , StringComparison . InvariantCultureIgnoreCase ) ) ) ;
You can’t perform that action at this time.
0 commit comments