31 lines
961 B
C#
31 lines
961 B
C#
using AspShogiSockets.ServiceModels.Api.Messages;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Websockets.Repositories;
|
|
|
|
namespace AspShogiSockets.Controllers
|
|
{
|
|
[Authorize]
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class GameController : ControllerBase
|
|
{
|
|
private readonly IGameboardRepository gameboardRepository;
|
|
|
|
public GameController(IGameboardRepository gameboardRepository)
|
|
{
|
|
this.gameboardRepository = gameboardRepository;
|
|
}
|
|
|
|
[Route("JoinCode")]
|
|
public async Task<IActionResult> PostGameInvitation([FromBody] PostGameInvitation request)
|
|
{
|
|
var userName = HttpContext.User.Claims.First(c => c.Type == "preferred_username").Value;
|
|
var code = (await gameboardRepository.PostJoinCode(request.SessionName, userName)).JoinCode;
|
|
return new CreatedResult("", new PostGameInvitationResponse(code));
|
|
}
|
|
}
|
|
}
|