using HopFrame.Api.Logic; using HopFrame.Database.Models; using HopFrame.Security.Authorization; using HopFrame.Security.Claims; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using RestApiTest.Models; namespace RestApiTest.Controllers; [ApiController] [Route("test")] public class TestController(ITokenContext userContext, DatabaseContext context, AdminContext adminContext) : ControllerBase { [HttpGet("permissions"), Authorized] public ActionResult> Permissions() { return new ActionResult>(userContext.User.Permissions); } [HttpGet("generate")] public async Task GenerateData() { var employee = new Employee() { Name = "Max Mustermann" }; await context.AddAsync(employee); await context.SaveChangesAsync(); var address = new Address() { City = "Musterstadt", Country = "Musterland", State = "Musterbundesland", ZipCode = 12345, AddressDetails = "Musterstraße 5", Employee = employee }; await context.AddAsync(address); await context.SaveChangesAsync(); return LogicResult.Ok(); } [HttpGet("employees")] public async Task>> GetEmployees() { return LogicResult>.Ok(await context.Employees.Include(e => e.Address).ToListAsync()); } [HttpGet("addresses")] public async Task>> GetAddresses() { return LogicResult>.Ok(await context.Addresses.Include(e => e.Employee).ToListAsync()); } [HttpGet("adminContext")] public ActionResult GetAdminContext() { return LogicResult.Ok(adminContext); } }