29 lines
695 B
C#
29 lines
695 B
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using NoticeBoard.Data;
|
|
|
|
namespace NoticeBoard.Controllers;
|
|
|
|
[Authorize]
|
|
public class AdminController : Controller
|
|
{
|
|
private readonly AppDbContext _db;
|
|
|
|
public AdminController(AppDbContext db)
|
|
{
|
|
_db = db;
|
|
}
|
|
|
|
public async Task<IActionResult> 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();
|
|
}
|
|
}
|