fix: show include in world settings

This commit is contained in:
CyberL1 2024-02-23 12:43:00 +01:00
parent 0a9cb2d41c
commit 2b1c55d030
3 changed files with 3 additions and 4 deletions

View File

@ -99,7 +99,7 @@ namespace Minecraft_Realms_Emulator.Controllers
if (body.Name == playerName) return Forbid("You cannot invite yourself"); if (body.Name == playerName) return Forbid("You cannot invite yourself");
var world = await _context.Worlds.FirstOrDefaultAsync(w => w.Id == wId); var world = await _context.Worlds.Include(w => w.Players).FirstOrDefaultAsync(w => w.Id == wId);
if (world == null) return NotFound("World not found"); if (world == null) return NotFound("World not found");
@ -118,7 +118,6 @@ namespace Minecraft_Realms_Emulator.Controllers
}; };
_context.Players.Add(player); _context.Players.Add(player);
// world.Players.Add(player);
Invite invite = new() Invite invite = new()
{ {

View File

@ -72,7 +72,7 @@ namespace Minecraft_Realms_Emulator.Controllers
[HttpGet("{id}")] [HttpGet("{id}")]
public async Task<ActionResult<World>> GetWorldById(int id) public async Task<ActionResult<World>> GetWorldById(int id)
{ {
var world = await _context.Worlds.FindAsync(id); var world = await _context.Worlds.Include(w => w.Players).FirstOrDefaultAsync(w => w.Id == id);
if (world == null) return NotFound("World not found"); if (world == null) return NotFound("World not found");

View File

@ -5,7 +5,7 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddControllers(); builder.Services.AddControllers().AddJsonOptions(x => x.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();