Reorganized project in solution folders

This commit is contained in:
2024-11-24 10:42:33 +01:00
parent 4a5855250c
commit 1897428d00
34 changed files with 17 additions and 4 deletions

View File

@@ -0,0 +1,54 @@
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) : ControllerBase {
[HttpGet("permissions"), Authorized]
public ActionResult<IList<Permission>> Permissions() {
return new ActionResult<IList<Permission>>(userContext.User.Permissions);
}
[HttpGet("generate")]
public async Task<ActionResult> 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<ActionResult<IList<Employee>>> GetEmployees() {
return LogicResult<IList<Employee>>.Ok(await context.Employees.Include(e => e.Address).ToListAsync());
}
[HttpGet("addresses")]
public async Task<ActionResult<IList<Address>>> GetAddresses() {
return LogicResult<IList<Address>>.Ok(await context.Addresses.Include(e => e.Employee).ToListAsync());
}
}