I don't know what I'm doing anymore

This commit is contained in:
Michele 2020-11-16 00:03:42 +00:00
parent ea9cc32534
commit 8fdee0cb67
17 changed files with 342 additions and 116 deletions

View file

@ -1,3 +1,4 @@
using System.Net;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -17,48 +18,50 @@ namespace Sledgemapper.Api.Controllers
public SessionController(IMediator mediator) { _mediator = mediator; }
[HttpPost]
public async Task Post(string sessionName)
public async Task<bool> Post(string sessionName)
{
var userId = int.Parse(HttpContext.User.Identity.Name);
var result = await _mediator.Send(new NewSessionCommand(sessionName, userId));
}
return result;
}
[HttpPost("tile")]
public async Task Post(string sessionName, [FromBody]Tile tile)
public async Task Post(string sessionName, [FromBody] Tile tile)
{
await _mediator.Publish(new NewTileNotification(sessionName, tile));
var userId = int.Parse(HttpContext.User.Identity.Name);
await _mediator.Send(new SaveNewTileCommand(sessionName, tile, userId));
}
[HttpPost("overlay")]
public async Task Post(string sessionName, [FromBody]Overlay overlay)
public async Task Post(string sessionName, [FromBody] Overlay overlay)
{
await _mediator.Publish(new NewOverlayNotification(sessionName, overlay));
}
[HttpPost("wall")]
public async Task Post(string sessionName, [FromBody]Wall wall)
[HttpPost("wall")]
public async Task Post(string sessionName, [FromBody] Wall wall)
{
await _mediator.Publish(new NewWallNotification(sessionName, wall));
}
[HttpDelete("tile")]
public async Task Delete(string sessionName, [FromBody]Tile tile)
[HttpDelete("tile")]
public async Task Delete(string sessionName, [FromBody] Tile tile)
{
await _mediator.Publish(new DeleteTileNotification(sessionName, tile));
}
[HttpDelete("overlay")]
public async Task Delete(string sessionName, [FromBody]Overlay overlay)
public async Task Delete(string sessionName, [FromBody] Overlay overlay)
{
await _mediator.Publish(new DeleteOverlayNotification(sessionName, overlay));
}
[HttpDelete("wall")]
public async Task Delete(string sessionName, [FromBody]Wall wall)
[HttpDelete("wall")]
public async Task Delete(string sessionName, [FromBody] Wall wall)
{
await _mediator.Publish(new DeleteWallNotification(sessionName, wall));
}
}
}