Skip to content

Instantly share code, notes, and snippets.

@cbdribamar
Created February 11, 2026 12:04
Show Gist options
  • Select an option

  • Save cbdribamar/3b7bfacfb65a7401d91f646484ee77d8 to your computer and use it in GitHub Desktop.

Select an option

Save cbdribamar/3b7bfacfb65a7401d91f646484ee77d8 to your computer and use it in GitHub Desktop.
Interview | Q1
[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