File tree 1 file changed +15
-0
lines changed
src/Services/Catalog/Catalog.API/Controllers
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,21 @@ public async Task<ActionResult<IEnumerable<Product>>> GetProductByCategory(strin
56
56
return Ok ( products ) ;
57
57
}
58
58
59
+ [ Route ( "[action]/{name}" , Name = "GetProductByName" ) ]
60
+ [ HttpGet ]
61
+ [ ProducesResponseType ( ( int ) HttpStatusCode . NotFound ) ]
62
+ [ ProducesResponseType ( typeof ( IEnumerable < Product > ) , ( int ) HttpStatusCode . OK ) ]
63
+ public async Task < ActionResult < IEnumerable < Product > > > GetProductByName ( string name )
64
+ {
65
+ var items = await _repository . GetProductByName ( name ) ;
66
+ if ( items == null )
67
+ {
68
+ _logger . LogError ( $ "Products with name: { name } not found.") ;
69
+ return NotFound ( ) ;
70
+ }
71
+ return Ok ( items ) ;
72
+ }
73
+
59
74
[ HttpPost ]
60
75
[ ProducesResponseType ( typeof ( Product ) , ( int ) HttpStatusCode . OK ) ]
61
76
public async Task < ActionResult < Product > > CreateProduct ( [ FromBody ] Product product )
You can’t perform that action at this time.
0 commit comments