Created
February 11, 2026 15:28
-
-
Save cbdribamar/dd27cdb9bb8e598198025826c7de30a3 to your computer and use it in GitHub Desktop.
Interview | Q2
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
| 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