summaryrefslogtreecommitdiff
path: root/Pages/ViewMedia.cshtml.cs
blob: fe8d150872da68e98ec4895055977fda14ffa0e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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();
    }
}