From 6ea277e1649f1fc1c401d4a64066f7cdf2610bb1 Mon Sep 17 00:00:00 2001 From: jessikitty Date: Wed, 20 May 2026 15:14:00 +1000 Subject: [PATCH] =?UTF-8?q?v1.0.0:=20Controllers=20=E2=80=94=20Admin,=20Sl?= =?UTF-8?q?ides,=20Devices,=20Display,=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/AdminController.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Controllers/AdminController.cs diff --git a/Controllers/AdminController.cs b/Controllers/AdminController.cs new file mode 100644 index 0000000..dd35ae2 --- /dev/null +++ b/Controllers/AdminController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using NoticeBoard.Data; + +namespace NoticeBoard.Controllers; + +public class AdminController : Controller +{ + private readonly AppDbContext _db; + + public AdminController(AppDbContext db) + { + _db = db; + } + + public async Task Index() + { + ViewBag.SlideCount = await _db.Slides.CountAsync(); + ViewBag.DeviceCount = await _db.Devices.CountAsync(); + ViewBag.Devices = await _db.Devices + .Include(d => d.DeviceSlides) + .OrderBy(d => d.Name) + .ToListAsync(); + return View(); + } +}