summaryrefslogtreecommitdiff
path: root/DSACore/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'DSACore/Controllers')
-rw-r--r--DSACore/Controllers/CommandsController.cs19
-rw-r--r--DSACore/Controllers/LobbyController.cs19
-rw-r--r--DSACore/Controllers/TokensController.cs11
3 files changed, 16 insertions, 33 deletions
diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs
index b6e0be2..2edbbaf 100644
--- a/DSACore/Controllers/CommandsController.cs
+++ b/DSACore/Controllers/CommandsController.cs
@@ -1,20 +1,16 @@
using System;
-using DSACore.Models.Network;
using DSALib.Commands;
using DSALib.Models.Network;
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
-namespace DSACore.Controllers
-{
+namespace DSACore.Controllers {
[Route("dsa/[controller]")]
- public class CommandsController : Controller
- {
+ public class CommandsController : Controller {
// GET: api/<controller>
[HttpGet]
- public string Get()
- {
+ public string Get() {
return "Usage: post the command to execute";
}
@@ -27,14 +23,11 @@ namespace DSACore.Controllers
// POST api/<controller>/Felis
[HttpPost]
- public string Post([FromBody] Command cmd)
- {
- try
- {
+ public string Post([FromBody] Command cmd) {
+ try {
return CommandHandler.ExecuteCommand(cmd).message;
}
- catch (Exception e)
- {
+ catch (Exception e) {
return $"Ein Fehler ist aufgetreten: \n {e.Message}";
}
}
diff --git a/DSACore/Controllers/LobbyController.cs b/DSACore/Controllers/LobbyController.cs
index 7890b4f..41ce436 100644
--- a/DSACore/Controllers/LobbyController.cs
+++ b/DSACore/Controllers/LobbyController.cs
@@ -1,30 +1,23 @@
using System;
-using DSACore.Models.Network;
using DSALib.Commands;
using DSALib.Models.Network;
using Microsoft.AspNetCore.Mvc;
-namespace DSACore.Controllers
-{
- public class ScribbleController : Controller
- {
+namespace DSACore.Controllers {
+ public class ScribbleController : Controller {
[Route("[controller]")]
// GET: api/<controller>
[HttpGet]
- public string Get()
- {
+ public string Get() {
return "Usage: get /tokens/{Token}";
}
[HttpPost]
- public string Post([FromBody] Command cmd)
- {
- try
- {
+ public string Post([FromBody] Command cmd) {
+ try {
return CommandHandler.ExecuteCommand(cmd).message;
}
- catch (Exception e)
- {
+ catch (Exception e) {
return $"Ein Fehler ist aufgetreten: \n {e.Message}";
}
}
diff --git a/DSACore/Controllers/TokensController.cs b/DSACore/Controllers/TokensController.cs
index a85cabe..f1ddb37 100644
--- a/DSACore/Controllers/TokensController.cs
+++ b/DSACore/Controllers/TokensController.cs
@@ -1,21 +1,18 @@
using DSACore.Hubs;
using Microsoft.AspNetCore.Mvc;
-namespace DSACore.Controllers
-{
+namespace DSACore.Controllers {
[Route("lobby/[controller]")]
[ApiController]
- public class TokensController : Controller
- {
+ public class TokensController : Controller {
// GET
[HttpGet("{token}")]
- public ActionResult<string> Get(string token)
- {
+ public ActionResult<string> Get(string token) {
if (!int.TryParse(token, out var intToken))
return BadRequest("The token has to be a 32 bit unsigned integer");
if (intToken == 42) return Ok("Scribble");
-
+
if (!Users.Tokens.Exists(x => x.GetHashCode() == intToken)) return NotFound();
var group = Users.Tokens.Find(x => x.GetHashCode() == intToken);