|
6 | 6 | using System.Threading.Tasks; |
7 | 7 | using Microsoft.AspNetCore.Mvc; |
8 | 8 | using contentstack_liquid_template_example.Models; |
9 | | -using Contentstack.Core; |
10 | | -using Contentstack.Core.Models; |
11 | | -using System.IO; |
12 | | - |
| 9 | +using Contentstack.Core; |
| 10 | +using Contentstack.Core.Models; |
| 11 | +using System.IO; |
| 12 | + |
13 | 13 | namespace contentstack_liquid_template_example.Controllers |
14 | 14 | { |
15 | 15 | public class HomeController : Controller |
16 | | - { |
17 | | - private readonly ContentstackClient _stack; |
18 | | - public HomeController(ContentstackClient stack) => _stack = stack; |
| 16 | + { |
| 17 | + private readonly ContentstackClient _stack; |
| 18 | + public HomeController(ContentstackClient stack) => _stack = stack; |
19 | 19 |
|
| 20 | + [HttpGet] |
20 | 21 | public async Task<IActionResult> Index() |
21 | | - { |
22 | | - string result = string.Empty; |
23 | | - var query = _stack.ContentType("product").Query(); |
24 | | - ContentstackCollection<ProductModel> products = await query.Find<ProductModel>(); |
25 | | - var fileString = System.IO.File.ReadAllText(Path.GetFullPath("Views/Home/home.liquid")); |
26 | | - var template = Template.Parse(fileString); |
27 | | - result = template.Render(new { Products = products.Items }); |
28 | | - return View("Index", result); |
| 22 | + { |
| 23 | + string result = string.Empty; |
| 24 | + var query = _stack.ContentType("product").Query(); |
| 25 | + ContentstackCollection<ProductModel> products = await query.Find<ProductModel>(); |
| 26 | + var fileString = System.IO.File.ReadAllText(Path.GetFullPath("Views/Home/home.liquid")); |
| 27 | + var template = Template.Parse(fileString); |
| 28 | + result = template.Render(new { Products = products.Items }); |
| 29 | + return View("Index", result); |
29 | 30 | } |
30 | 31 |
|
| 32 | + [HttpGet] |
31 | 33 | public IActionResult Privacy() |
32 | 34 | { |
33 | 35 | return View(); |
34 | 36 | } |
35 | 37 |
|
| 38 | + [HttpGet] |
36 | 39 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] |
37 | 40 | public IActionResult Error() |
38 | 41 | { |
|
0 commit comments