implement two queries
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using AipsCore.Application.Abstract;
|
||||
using AipsCore.Application.Models.Whiteboard.Command.AddUserToWhiteboard;
|
||||
using AipsCore.Application.Models.Whiteboard.Command.CreateWhiteboard;
|
||||
using AipsCore.Application.Models.Whiteboard.Query.GetRecentWhiteboards;
|
||||
using AipsCore.Domain.Models.Whiteboard;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace AipsWebApi.Controllers;
|
||||
@@ -9,18 +11,33 @@ namespace AipsWebApi.Controllers;
|
||||
[Route("[controller]")]
|
||||
public class WhiteboardController : ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<int>> CreateWhiteboard(CreateWhiteboardCommand command, IDispatcher dispatcher, CancellationToken cancellationToken)
|
||||
private readonly IDispatcher _dispatcher;
|
||||
|
||||
public WhiteboardController(IDispatcher dispatcher)
|
||||
{
|
||||
var whiteboardId = await dispatcher.Execute(command, cancellationToken);
|
||||
_dispatcher = dispatcher;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<int>> CreateWhiteboard(CreateWhiteboardCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var whiteboardId = await _dispatcher.Execute(command, cancellationToken);
|
||||
return Ok(whiteboardId.IdValue);
|
||||
}
|
||||
|
||||
[HttpPost("adduser")]
|
||||
public async Task<IActionResult> AddUser(AddUserToWhiteboardCommand command, IDispatcher dispatcher,
|
||||
public async Task<IActionResult> AddUser(AddUserToWhiteboardCommand command,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
await dispatcher.Execute(command, cancellationToken);
|
||||
await _dispatcher.Execute(command, cancellationToken);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet("recent")]
|
||||
public async Task<ActionResult<ICollection<Whiteboard>>> Recent(GetRecentWhiteboardsQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await _dispatcher.Execute(query, cancellationToken);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user