aboutsummaryrefslogtreecommitdiffstats
path: root/src/Pages/Index.cshtml.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-06-01 21:13:43 +0200
committerivarlovlie <git@ivarlovlie.no>2022-06-01 21:13:43 +0200
commit9383a2fb09ffb60cfe63683106945bd688affa59 (patch)
tree65b3f4b48841583e355887db5de5a16e7005fc87 /src/Pages/Index.cshtml.cs
downloadvinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.tar.xz
vinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.zip
feat: Initial commit after clean slate
Diffstat (limited to 'src/Pages/Index.cshtml.cs')
-rw-r--r--src/Pages/Index.cshtml.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Pages/Index.cshtml.cs b/src/Pages/Index.cshtml.cs
new file mode 100644
index 0000000..3cefa0d
--- /dev/null
+++ b/src/Pages/Index.cshtml.cs
@@ -0,0 +1,34 @@
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+using Microsoft.EntityFrameworkCore;
+using VSH.Data;
+using VSH.Data.Database;
+using VSH.Data.Enums;
+
+namespace VSH.Pages;
+
+public class IndexModel : PageModel
+{
+ private readonly MainDbContext _context;
+
+ public string ContactHtml { get; set; }
+ public List<Product> HighlightedProducts { get; set; } = new();
+
+ public IndexModel(MainDbContext context) {
+ _context = context;
+ }
+
+ public ActionResult OnGet() {
+ ContactHtml = _context.Documents.OrderBy(c => c.Created)
+ .LastOrDefault(c => c.Type == DocumentType.CONTACT_PAGE)
+ ?.Content;
+ HighlightedProducts = _context.Products
+ .Where(c => c.ShowOnFrontpage
+ && c.VisibilityState == ProductVisibility.DEFAULT)
+ .Include(c => c.Category)
+ .ToList();
+ return Page();
+ }
+} \ No newline at end of file