small fixes
This commit is contained in:
parent
22233f8c6e
commit
acc9fbeeb7
1 changed files with 11 additions and 19 deletions
|
@ -12,21 +12,20 @@ namespace Sledgemapper.Api.Controllers
|
||||||
public class SessionController : ControllerBase
|
public class SessionController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
|
private int UserId => int.Parse(HttpContext.User.Identity.Name);
|
||||||
public SessionController(IMediator mediator) { _mediator = mediator; }
|
|
||||||
|
public SessionController(IMediator mediator) => _mediator = mediator;
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<bool> 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));
|
||||||
var result = await _mediator.Send(new NewSessionCommand(sessionName, userId));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<Session> Get(string sessionName)
|
public async Task<Session> Get(string sessionName)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
|
||||||
var result = await _mediator.Send(new GetMapSnapshotCommand(sessionName));
|
var result = await _mediator.Send(new GetMapSnapshotCommand(sessionName));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -34,50 +33,43 @@ namespace Sledgemapper.Api.Controllers
|
||||||
[HttpPost("snapshot")]
|
[HttpPost("snapshot")]
|
||||||
public async Task Post(string sessionName, [FromBody] Session session)
|
public async Task Post(string sessionName, [FromBody] Session session)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
await _mediator.Send(new NewSnapshotCommand(sessionName, session, UserId));
|
||||||
await _mediator.Send(new NewSnapshotCommand(sessionName, session, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("tile")]
|
[HttpPost("tile")]
|
||||||
public async Task Post(string sessionName, [FromBody] Tile tile)
|
public async Task Post(string sessionName, [FromBody] Tile tile)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
await _mediator.Send(new NewTileCommand(sessionName, tile, UserId));
|
||||||
await _mediator.Send(new NewTileCommand(sessionName, tile, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("overlay")]
|
[HttpPost("overlay")]
|
||||||
public async Task Post(string sessionName, [FromBody] Overlay overlay)
|
public async Task Post(string sessionName, [FromBody] Overlay overlay)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
await _mediator.Send(new NewOverlayCommand(sessionName, overlay, UserId));
|
||||||
await _mediator.Send(new NewOverlayCommand(sessionName, overlay, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("wall")]
|
[HttpPost("wall")]
|
||||||
public async Task Post(string sessionName, [FromBody] Wall wall)
|
public async Task Post(string sessionName, [FromBody] Wall wall)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
await _mediator.Send(new NewWallCommand(sessionName, wall, UserId));
|
||||||
await _mediator.Send(new NewWallCommand(sessionName, wall, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("tile")]
|
[HttpDelete("tile")]
|
||||||
public async Task Delete(string sessionName, [FromBody] Tile tile)
|
public async Task Delete(string sessionName, [FromBody] Tile tile)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
await _mediator.Send(new DeleteTileCommand(sessionName, tile, UserId));
|
||||||
await _mediator.Send(new DeleteTileCommand(sessionName, tile, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("overlay")]
|
[HttpDelete("overlay")]
|
||||||
public async Task Delete(string sessionName, [FromBody] Overlay overlay)
|
public async Task Delete(string sessionName, [FromBody] Overlay overlay)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
await _mediator.Send(new DeleteOverlayCommand(sessionName, overlay, UserId));
|
||||||
await _mediator.Send(new DeleteOverlayCommand(sessionName, overlay, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("wall")]
|
[HttpDelete("wall")]
|
||||||
public async Task Delete(string sessionName, [FromBody] Wall wall)
|
public async Task Delete(string sessionName, [FromBody] Wall wall)
|
||||||
{
|
{
|
||||||
var userId = int.Parse(HttpContext.User.Identity.Name);
|
await _mediator.Send(new DeleteWallCommand(sessionName, wall, UserId));
|
||||||
await _mediator.Send(new DeleteWallCommand(sessionName, wall, userId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue