Editor povezava na db
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
using System.Data.Entity;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using ZpcBulletinBoard.Data;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.Editor
|
||||
{
|
||||
public class EditMainModel(ILogger<EditMainModel> logger) : PageModel
|
||||
[Authorize]
|
||||
public class EditMainModel(ILogger<EditMainModel> logger, ApplicationDbContext context) : PageModel
|
||||
{
|
||||
private readonly ILogger<EditMainModel> _logger = logger;
|
||||
|
||||
@@ -11,5 +15,20 @@ namespace ZpcBulletinBoard.Pages.Editor
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user