Skip to content

Commit

Permalink
GetProductByName
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetozkaya committed Apr 12, 2021
1 parent 8e6fcbf commit 0c0bac5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ public async Task<ActionResult<IEnumerable<Product>>> GetProductByCategory(strin
return Ok(products);
}

[Route("[action]/{name}", Name = "GetProductByName")]
[HttpGet]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
[ProducesResponseType(typeof(IEnumerable<Product>), (int)HttpStatusCode.OK)]
public async Task<ActionResult<IEnumerable<Product>>> GetProductByName(string name)
{
var items = await _repository.GetProductByName(name);
if (items == null)
{
_logger.LogError($"Products with name: {name} not found.");
return NotFound();
}
return Ok(items);
}

[HttpPost]
[ProducesResponseType(typeof(Product), (int)HttpStatusCode.OK)]
public async Task<ActionResult<Product>> CreateProduct([FromBody] Product product)
Expand Down

0 comments on commit 0c0bac5

Please sign in to comment.