tentative campaign map management
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c46e66595b
commit
4c345bd044
37 changed files with 1693 additions and 50 deletions
|
@ -3,83 +3,84 @@ using Microsoft.AspNetCore.Authorization;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Sledgemapper.Api.Commands;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("[controller]/{mapName}")]
|
||||
[Route("[controller]/{campaign}/{mapName}")]
|
||||
public class MapController : ControllerBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private int UserId => int.Parse(HttpContext.User.Identity.Name);
|
||||
private string UserId => HttpContext.User.Claims.FirstOrDefault(m => m.Type == "Id").Value;
|
||||
|
||||
public MapController(IMediator mediator) => _mediator = mediator;
|
||||
|
||||
[HttpPost]
|
||||
public async Task<bool> Post(string mapName)
|
||||
public async Task<bool> Post(string campaign, string mapName)
|
||||
{
|
||||
var result = await _mediator.Send(new NewSessionCommand(mapName, UserId));
|
||||
var result = await _mediator.Send(new NewSessionCommand(campaign, mapName, UserId));
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<Session> Get(string mapName)
|
||||
public async Task<Session> Get(string campaign, string mapName)
|
||||
{
|
||||
var result = await _mediator.Send(new GetMapSnapshotCommand(mapName));
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost("snapshot")]
|
||||
public async Task Post(string mapName, [FromBody] Session session)
|
||||
public async Task Post(string campaign, string mapName, [FromBody] Session session)
|
||||
{
|
||||
await _mediator.Send(new NewSnapshotCommand(mapName, session, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("overlay")]
|
||||
public async Task Post(string mapName, [FromBody] Overlay overlay)
|
||||
public async Task Post(string campaign, string mapName, [FromBody] Overlay overlay)
|
||||
{
|
||||
await _mediator.Send(new NewOverlayCommand(mapName, overlay, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("wall")]
|
||||
public async Task Post(string mapName, [FromBody] Wall wall)
|
||||
public async Task Post(string campaign, string mapName, [FromBody] Wall wall)
|
||||
{
|
||||
await _mediator.Send(new NewWallCommand(mapName, wall, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("note")]
|
||||
public async Task Post(string mapName, [FromBody] Note note)
|
||||
public async Task Post(string campaign, string mapName, [FromBody] Note note)
|
||||
{
|
||||
await _mediator.Send(new NewNoteCommand(mapName, note, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("room")]
|
||||
public async Task Post(string mapName, [FromBody] Room room)
|
||||
public async Task Post(string campaign, string mapName, [FromBody] Room room)
|
||||
{
|
||||
await _mediator.Send(new NewRoomCommand(mapName, room, UserId));
|
||||
}
|
||||
|
||||
[HttpPost("line")]
|
||||
public async Task Post(string mapName, [FromBody] Line line)
|
||||
public async Task Post(string campaign, string mapName, [FromBody] Line line)
|
||||
{
|
||||
await _mediator.Send(new NewLineCommand(mapName, line, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("overlay")]
|
||||
public async Task Delete(string mapName, [FromBody] Overlay overlay)
|
||||
public async Task Delete(string campaign, string mapName, [FromBody] Overlay overlay)
|
||||
{
|
||||
await _mediator.Send(new DeleteOverlayCommand(mapName, overlay, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("wall")]
|
||||
public async Task Delete(string mapName, [FromBody] Wall wall)
|
||||
public async Task Delete(string campaign, string mapName, [FromBody] Wall wall)
|
||||
{
|
||||
await _mediator.Send(new DeleteWallCommand(mapName, wall, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("note")]
|
||||
public async Task Delete(string mapName, [FromBody] Note note)
|
||||
public async Task Delete(string campaign, string mapName, [FromBody] Note note)
|
||||
{
|
||||
await _mediator.Send(new DeleteNoteCommand(mapName, note, UserId));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue