Files
zpc-bulletin-board/ZpcBulletinBoard/Pages/Editor/EditMain.cshtml.cs
2024-02-27 07:27:47 +01:00

35 lines
954 B
C#

using System.Data.Entity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using ZpcBulletinBoard.Data;
namespace ZpcBulletinBoard.Pages.Editor
{
[Authorize]
public class EditMainModel(ILogger<EditMainModel> logger, ApplicationDbContext context) : PageModel
{
private readonly ILogger<EditMainModel> _logger = logger;
public void OnGet()
{
}
public IActionResult OnGetBoards()
{
var boards= context.BulletinBoards.ToList();
return new JsonResult(new { successful = true, error = $"", boards });
}
public IActionResult OnGetBoard(int id)
{
var board = context.BulletinBoards.Include(x => x.Pages)
.FirstOrDefault(x => x.IdBulletinBoard == id);
return new JsonResult(new { successful = true, error = $"", board });
}
}
}