Skip to content

Instantly share code, notes, and snippets.

@cbdribamar
Created February 11, 2026 15:28
Show Gist options
  • Select an option

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

Select an option

Save cbdribamar/dd27cdb9bb8e598198025826c7de30a3 to your computer and use it in GitHub Desktop.
Interview | Q2
public class ProductsApiController : UmbracoApiController
{
[HttpGet]
public IActionResult GetProducts()
{
var products = Umbraco.ContentAtRoot()
.First()
.Descendants()
.Where(x => x.ContentType.Alias == "product");
var result = products.Select(p => new
{
Name = p.Name,
Category = Umbraco.Content(p.Value<int>("categoryId"))?.Name,
Price = p.Value<decimal>("price")
});
return Ok(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment