Created
February 11, 2026 12:04
-
-
Save cbdribamar/3b7bfacfb65a7401d91f646484ee77d8 to your computer and use it in GitHub Desktop.
Interview | Q1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ApiController] | |
| [Route("api/[controller]")] | |
| public class ProductsController : ControllerBase | |
| { | |
| [HttpGet("{id}")] | |
| public IActionResult GetProduct(int id) | |
| { | |
| var contentQuery = new PublishedContentQuery(); | |
| var product = contentQuery.Content(id); | |
| if (product == null) | |
| { | |
| return NotFound(); | |
| } | |
| var logger = new FileLogger("logs/products.txt"); | |
| logger.Log($"Product {id} retrieved"); | |
| return Ok(new | |
| { | |
| Name = product.Name, | |
| Price = product.Value<decimal>("price") | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment