54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
using AipsCore.Application.Abstract;
|
|
using AipsCore.Application.Models.Whiteboard.Command.CreateWhiteboard;
|
|
using AipsCore.Application.Models.Whiteboard.Query.GetRecentWhiteboards;
|
|
using AipsCore.Application.Models.Whiteboard.Query.GetWhiteboardHistory;
|
|
using AipsCore.Application.Models.WhiteboardMembership.Command.CreateWhiteboardMembership;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Whiteboard = AipsCore.Infrastructure.Persistence.Whiteboard.Whiteboard;
|
|
|
|
namespace AipsWebApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("/api/[controller]")]
|
|
public class WhiteboardController : ControllerBase
|
|
{
|
|
private readonly IDispatcher _dispatcher;
|
|
|
|
public WhiteboardController(IDispatcher dispatcher)
|
|
{
|
|
_dispatcher = dispatcher;
|
|
}
|
|
|
|
[Authorize]
|
|
[HttpPost]
|
|
public async Task<ActionResult<int>> CreateWhiteboard(CreateWhiteboardCommand command, CancellationToken cancellationToken)
|
|
{
|
|
var whiteboardId = await _dispatcher.Execute(command, cancellationToken);
|
|
return Ok(whiteboardId.IdValue);
|
|
}
|
|
|
|
[Authorize]
|
|
[HttpGet("history")]
|
|
public async Task<ActionResult<ICollection<Whiteboard>>> GetWhiteboardHistory(CancellationToken cancellationToken)
|
|
{
|
|
var whiteboards = await _dispatcher.Execute(new GetWhiteboardHistoryQuery(), cancellationToken);
|
|
return Ok(whiteboards);
|
|
}
|
|
|
|
[Authorize]
|
|
[HttpGet("recent")]
|
|
public async Task<ActionResult<ICollection<Whiteboard>>> GetRecentWhiteboards(CancellationToken cancellationToken)
|
|
{
|
|
var whiteboards = await _dispatcher.Execute(new GetRecentWhiteboardsQuery(), cancellationToken);
|
|
return Ok(whiteboards);
|
|
}
|
|
|
|
[Authorize]
|
|
[HttpPost("join")]
|
|
public async Task<ActionResult> JoinWhiteboard(CreateWhiteboardMembershipCommand command, CancellationToken cancellationToken)
|
|
{
|
|
var result = await _dispatcher.Execute(command, cancellationToken);
|
|
return Ok(result);
|
|
}
|
|
} |