From 4f0ac6ef5b425d01513ea091c62a932f8e263c85 Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Fri, 18 Sep 2020 00:14:50 +1000 Subject: [PATCH] there is now a shitty document viewer --- Pages/Documents/View.cshtml | 10 ++++++++++ Pages/Documents/View.cshtml.cs | 31 +++++++++++++++++++++++++++++++ Pages/Index.cshtml | 2 +- Pages/Shared/_Layout.cshtml | 4 ++-- wwwroot/css/style.css | 26 ++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 Pages/Documents/View.cshtml create mode 100644 Pages/Documents/View.cshtml.cs diff --git a/Pages/Documents/View.cshtml b/Pages/Documents/View.cshtml new file mode 100644 index 0000000..0db8525 --- /dev/null +++ b/Pages/Documents/View.cshtml @@ -0,0 +1,10 @@ +@page "{id:int}" +@model Snootalogue.Pages.Documents.ViewModel + +@{ + ViewData["Title"] = $"Viewing \"{Model.Document.Title}\""; + ViewData["SlimNavbar"] = true; + ViewData["NoMainPadding"] = true; +} + + \ No newline at end of file diff --git a/Pages/Documents/View.cshtml.cs b/Pages/Documents/View.cshtml.cs new file mode 100644 index 0000000..f7d6ea2 --- /dev/null +++ b/Pages/Documents/View.cshtml.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.EntityFrameworkCore; +using Snootalogue.Data; +using Snootalogue.Models; + +namespace Snootalogue.Pages.Documents { + public class ViewModel : PageModel { + private readonly SnootalogueContext _context; + public Document Document { get; set; } + + public ViewModel(SnootalogueContext context) { + _context = context; + } + + public async Task OnGetAsync(int? id) { + if (id == null) { + return NotFound(); + } + + Document = await _context.Document.FirstOrDefaultAsync(d => d.ID == id); + + if (Document == null) { + return NotFound(); + } + + return Page(); + } + } +} diff --git a/Pages/Index.cshtml b/Pages/Index.cshtml index 1377e23..75b823e 100644 --- a/Pages/Index.cshtml +++ b/Pages/Index.cshtml @@ -12,7 +12,7 @@
- +
By @Html.DisplayFor(modelItem => item.Authors)
Category: @Html.DisplayFor(modelItem => item.Category)
@Html.DisplayFor(modelItem => item.Tags)
diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml index 4fe835c..729d427 100644 --- a/Pages/Shared/_Layout.cshtml +++ b/Pages/Shared/_Layout.cshtml @@ -9,7 +9,7 @@ -