From 701d474949e5cb72b8ed7b29fec45ad74580f570 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Tue, 8 Aug 2023 13:20:21 +1000 Subject: Initial commit --- Pages/ViewMedia.cshtml.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Pages/ViewMedia.cshtml.cs (limited to 'Pages/ViewMedia.cshtml.cs') diff --git a/Pages/ViewMedia.cshtml.cs b/Pages/ViewMedia.cshtml.cs new file mode 100644 index 0000000..fe8d150 --- /dev/null +++ b/Pages/ViewMedia.cshtml.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace HyperBooru.Pages; + +public class ViewMediaModel : PageModel { + public DbMedia Media { get; private set; } + + private HyperBooruDbContext db; + + public ViewMediaModel(HyperBooruDbContext db) => + this.db = db; + + public IActionResult OnGet([FromQuery(Name = "m")] Guid mediaId) { + var media = db.Media.First(m => m.Guid == mediaId); + if(media is null) + return NotFound(); + + Media = media; + + return Page(); + } +} \ No newline at end of file -- cgit v1.3