Editor povezava na db

This commit is contained in:
David Štaleker
2024-02-27 07:27:47 +01:00
parent 4df426dc10
commit e92956075f
24 changed files with 1033 additions and 47 deletions

View File

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