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 OrdersApiController : UmbracoApiController | |
| { | |
| private readonly IUmbracoDatabase _database; | |
| public OrdersApiController(IUmbracoDatabase database) | |
| { | |
| _database = database; | |
| } | |
| [HttpPost] |
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"); | |
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); | |