Created AdminContext handling
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using FrontendTest;
|
||||
using FrontendTest.Components;
|
||||
using HopFrame.Web;
|
||||
using HopFrame.Web.Admin;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
||||
26
test/RestApiTest/AdminContext.cs
Normal file
26
test/RestApiTest/AdminContext.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel;
|
||||
using HopFrame.Database.Models;
|
||||
using HopFrame.Web.Admin;
|
||||
using HopFrame.Web.Admin.Generators;
|
||||
using HopFrame.Web.Admin.Models;
|
||||
|
||||
namespace RestApiTest;
|
||||
|
||||
public class AdminContext : AdminPagesContext {
|
||||
|
||||
public AdminPage<User> Users { get; set; }
|
||||
public AdminPage<PermissionGroup> Groups { get; set; }
|
||||
|
||||
public override void OnModelCreating(IAdminContextGenerator generator) {
|
||||
|
||||
/*generator.Page<User>()
|
||||
.Title("Users")
|
||||
.Description("On this page you can manage all user accounts.")
|
||||
.UpdatePermission("update")
|
||||
.ViewPermission("view")
|
||||
.DeletePermission("delete")
|
||||
.CreatePermission("create")
|
||||
.DefaultSort(u => u.Id, ListSortDirection.Descending);*/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace RestApiTest.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("test")]
|
||||
public class TestController(ITokenContext userContext, DatabaseContext context) : ControllerBase {
|
||||
public class TestController(ITokenContext userContext, DatabaseContext context, AdminContext adminContext) : ControllerBase {
|
||||
|
||||
[HttpGet("permissions"), Authorized]
|
||||
public ActionResult<IList<Permission>> Permissions() {
|
||||
@@ -50,5 +50,10 @@ public class TestController(ITokenContext userContext, DatabaseContext context)
|
||||
public async Task<ActionResult<IList<Address>>> GetAddresses() {
|
||||
return LogicResult<IList<Address>>.Ok(await context.Addresses.Include(e => e.Employee).ToListAsync());
|
||||
}
|
||||
|
||||
[HttpGet("adminContext")]
|
||||
public ActionResult<AdminContext> GetAdminContext() {
|
||||
return LogicResult<AdminContext>.Ok(adminContext);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using RestApiTest;
|
||||
using HopFrame.Api.Extensions;
|
||||
using HopFrame.Web.Admin;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -13,6 +14,7 @@ builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddDbContext<DatabaseContext>();
|
||||
builder.Services.AddAdminContext<AdminContext>();
|
||||
|
||||
builder.Services.AddSwaggerGen(c => {
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme {
|
||||
|
||||
Reference in New Issue
Block a user