This commit is contained in:
parent
17d6cd28d6
commit
7e3e645fc9
48 changed files with 1530 additions and 1538 deletions
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Sledgemapper.Api.Commands;
|
||||
using Sledgemapper.Shared.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sledgemapper.Api.Controllers
|
||||
{
|
||||
|
@ -14,15 +14,30 @@ namespace Sledgemapper.Api.Controllers
|
|||
public class MapController : ControllerBase
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public MapController(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
private string UserId => HttpContext.User.Claims.FirstOrDefault(m => m.Type == "Id").Value;
|
||||
|
||||
public MapController(IMediator mediator) => _mediator = mediator;
|
||||
|
||||
[HttpPost]
|
||||
public async Task<Guid> Post(string campaign, string mapName)
|
||||
[HttpDelete("overlay")]
|
||||
public async Task Delete(Guid campaign, Guid mapName, [FromBody] Overlay overlay)
|
||||
{
|
||||
var result = await _mediator.Send(new NewSessionCommand(campaign, mapName, UserId));
|
||||
return result;
|
||||
await _mediator.Send(new DeleteOverlayCommand(campaign, mapName, overlay, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("wall")]
|
||||
public async Task Delete(Guid campaign, Guid mapName, [FromBody] Wall wall)
|
||||
{
|
||||
await _mediator.Send(new DeleteWallCommand(campaign, mapName, wall, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("note")]
|
||||
public async Task Delete(Guid campaign, Guid mapName, [FromBody] Note note)
|
||||
{
|
||||
await _mediator.Send(new DeleteNoteCommand(campaign, mapName, note, UserId));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
@ -32,6 +47,13 @@ namespace Sledgemapper.Api.Controllers
|
|||
return result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<Guid> Post(string campaign, string mapName)
|
||||
{
|
||||
var result = await _mediator.Send(new NewSessionCommand(campaign, mapName, UserId));
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost("snapshot")]
|
||||
public async Task Post(string campaign, string mapName, [FromBody] Session session)
|
||||
{
|
||||
|
@ -67,23 +89,5 @@ namespace Sledgemapper.Api.Controllers
|
|||
{
|
||||
await _mediator.Send(new NewLineCommand(campaign, mapName, line, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("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 campaign, string mapName, [FromBody] Wall wall)
|
||||
{
|
||||
await _mediator.Send(new DeleteWallCommand(mapName, wall, UserId));
|
||||
}
|
||||
|
||||
[HttpDelete("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