db and auth refactoring
This commit is contained in:
parent
0e1c16ab91
commit
aa472f9e29
45 changed files with 2182 additions and 697 deletions
|
@ -9,98 +9,82 @@ using System.Threading.Tasks;
|
|||
namespace Sledgemapper.Api.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("[controller]/{sessionName}")]
|
||||
public class SessionController : ControllerBase
|
||||
[Route("[controller]/{mapName}")]
|
||||
public class MapController : ControllerBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private int UserId => int.Parse(HttpContext.User.Identity.Name);
|
||||
|
||||
public SessionController(IMediator mediator) => _mediator = mediator;
|
||||
public MapController(IMediator mediator) => _mediator = mediator;
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<bool> Post(string sessionName)
|
||||
public async Task<bool> Post(string mapName)
|
||||
{
|
||||
var result = await _mediator.Send(new NewSessionCommand(sessionName, UserId));
|
||||
var result = await _mediator.Send(new NewSessionCommand(mapName, UserId));
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<Session> Get(string sessionName)
|
||||
public async Task<Session> Get(string mapName)
|
||||
{
|
||||
var result = await _mediator.Send(new GetMapSnapshotCommand(sessionName));
|
||||
var result = await _mediator.Send(new GetMapSnapshotCommand(mapName));
|
||||
return result;
|
||||
}
|
||||
|
||||
// [HttpPost("ping")]
|
||||
// public async Task Post(string sessionName, [FromBody] Ping pingLocation)
|
||||
// {
|
||||
// await _mediator.Send(new PingCommand(sessionName, pingLocation, UserId));
|
||||
// }
|
||||
|
||||
[HttpPost("snapshot")]
|
||||
public async Task Post(string sessionName, [FromBody] Session session)
|
||||
public async Task Post(string mapName, [FromBody] Session session)
|
||||
{
|
||||
await _mediator.Send(new NewSnapshotCommand(sessionName, session, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("tile")]
|
||||
public async Task Post(string sessionName, [FromBody] Tile tile)
|
||||
{
|
||||
await _mediator.Send(new NewTileCommand(sessionName, tile, UserId));
|
||||
await _mediator.Send(new NewSnapshotCommand(mapName, session, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("overlay")]
|
||||
public async Task Post(string sessionName, [FromBody] Overlay overlay)
|
||||
public async Task Post(string mapName, [FromBody] Overlay overlay)
|
||||
{
|
||||
await _mediator.Send(new NewOverlayCommand(sessionName, overlay, UserId));
|
||||
await _mediator.Send(new NewOverlayCommand(mapName, overlay, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("wall")]
|
||||
public async Task Post(string sessionName, [FromBody] Wall wall)
|
||||
public async Task Post(string mapName, [FromBody] Wall wall)
|
||||
{
|
||||
await _mediator.Send(new NewWallCommand(sessionName, wall, UserId));
|
||||
await _mediator.Send(new NewWallCommand(mapName, wall, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("note")]
|
||||
public async Task Post(string sessionName, [FromBody] Note note)
|
||||
public async Task Post(string mapName, [FromBody] Note note)
|
||||
{
|
||||
await _mediator.Send(new NewNoteCommand(sessionName, note, UserId));
|
||||
await _mediator.Send(new NewNoteCommand(mapName, note, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("room")]
|
||||
public async Task Post(string sessionName, [FromBody] Room room)
|
||||
public async Task Post(string mapName, [FromBody] Room room)
|
||||
{
|
||||
await _mediator.Send(new NewRoomCommand(sessionName, room, UserId));
|
||||
await _mediator.Send(new NewRoomCommand(mapName, room, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("line")]
|
||||
public async Task Post(string sessionName, [FromBody] Line line)
|
||||
public async Task Post(string mapName, [FromBody] Line line)
|
||||
{
|
||||
await _mediator.Send(new NewLineCommand(sessionName, line, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("tile")]
|
||||
public async Task Delete(string sessionName, [FromBody] Tile tile)
|
||||
{
|
||||
await _mediator.Send(new DeleteTileCommand(sessionName, tile, UserId));
|
||||
await _mediator.Send(new NewLineCommand(mapName, line, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("overlay")]
|
||||
public async Task Delete(string sessionName, [FromBody] Overlay overlay)
|
||||
public async Task Delete(string mapName, [FromBody] Overlay overlay)
|
||||
{
|
||||
await _mediator.Send(new DeleteOverlayCommand(sessionName, overlay, UserId));
|
||||
await _mediator.Send(new DeleteOverlayCommand(mapName, overlay, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("wall")]
|
||||
public async Task Delete(string sessionName, [FromBody] Wall wall)
|
||||
public async Task Delete(string mapName, [FromBody] Wall wall)
|
||||
{
|
||||
await _mediator.Send(new DeleteWallCommand(sessionName, wall, UserId));
|
||||
await _mediator.Send(new DeleteWallCommand(mapName, wall, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("note")]
|
||||
public async Task Delete(string sessionName, [FromBody] Note note)
|
||||
public async Task Delete(string mapName, [FromBody] Note note)
|
||||
{
|
||||
await _mediator.Send(new DeleteNoteCommand(sessionName, note, UserId));
|
||||
await _mediator.Send(new DeleteNoteCommand(mapName, note, UserId));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue