summaryrefslogtreecommitdiff
path: root/Pages/ViewMedia.cshtml.cs
blob: 476ea40ac77670d2bd76bbca4f859567a400f41c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace HyperBooru.Pages;

public class ViewMediaModel : PageModel {
    public DbMedia Media { get; private set; }

    public IEnumerable<DbTagDefinition> TagDefinitions =>
        db.TagDefinitions;

    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();
    }
}