mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using RadicadeServer.DB;
|
|
using RadicadeServer.Extensions;
|
|
using RadicadeServer.RecNet.Enums;
|
|
using RadicadeServer.RecNet.Matchmaking;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
using RadicadeServer.RecNet.Rooms;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace RadicadeServer.API.Matchmaking
|
|
{
|
|
[Route("api/quickPlay")]
|
|
public class QuickplayAPI : Controller
|
|
{
|
|
RecDBContext db;
|
|
public QuickplayAPI(RecDBContext context)
|
|
{
|
|
this.db = context;
|
|
}
|
|
|
|
[HttpGet("v1/getandclear"), Authorize]
|
|
public async Task<PlayerQuickPlayDTO?> GetAndClearQuickPlay()
|
|
{
|
|
var userId = User.GetUserId();
|
|
|
|
var presence = await db.Presences.FirstOrDefaultAsync((x) => x.playerId == userId);
|
|
var presenceRoomInstance = presence?.roomInstance;
|
|
RoomInstance? roomInstance = await db.RoomInstances.FirstOrDefaultAsync(x => x.roomInstanceId == presenceRoomInstance);
|
|
|
|
string roomTarget = "DormRoom";
|
|
if (roomInstance != null)
|
|
roomTarget = roomInstance.name;
|
|
|
|
return new PlayerQuickPlayDTO(null, roomTarget);
|
|
}
|
|
}
|
|
}
|