summaryrefslogtreecommitdiff
path: root/DSACore/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'DSACore/Controllers')
-rw-r--r--DSACore/Controllers/CommandsController.cs12
-rw-r--r--DSACore/Controllers/LobbyController.cs13
-rw-r--r--DSACore/Controllers/TokensController.cs19
3 files changed, 18 insertions, 26 deletions
diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs
index d35690c..5addf82 100644
--- a/DSACore/Controllers/CommandsController.cs
+++ b/DSACore/Controllers/CommandsController.cs
@@ -1,8 +1,5 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using DSACore.Models;
+using DSACore.Commands;
using DSACore.Models.Network;
using Microsoft.AspNetCore.Mvc;
@@ -29,17 +26,16 @@ namespace DSACore.Controllers
// POST api/<controller>/Felis
[HttpPost]
- public string Post([FromBody]Command cmd)
+ public string Post([FromBody] Command cmd)
{
try
{
- return Commands.CommandHandler.ExecuteCommand(cmd).message;
+ return CommandHandler.ExecuteCommand(cmd).message;
}
catch (Exception e)
{
return $"Ein Fehler ist aufgetreten: \n {e.Message}";
}
-
}
/*
@@ -56,4 +52,4 @@ namespace DSACore.Controllers
{
}*/
}
-}
+} \ No newline at end of file
diff --git a/DSACore/Controllers/LobbyController.cs b/DSACore/Controllers/LobbyController.cs
index a946184..df22607 100644
--- a/DSACore/Controllers/LobbyController.cs
+++ b/DSACore/Controllers/LobbyController.cs
@@ -1,5 +1,6 @@
-using DSACore.Models.Network;
using System;
+using DSACore.Commands;
+using DSACore.Models.Network;
using Microsoft.AspNetCore.Mvc;
namespace DSACore.Controllers
@@ -13,20 +14,18 @@ namespace DSACore.Controllers
{
return "Usage: get /tokens/{Token}";
}
-
+
[HttpPost]
- public string Post([FromBody]Command cmd)
+ public string Post([FromBody] Command cmd)
{
try
{
- return Commands.CommandHandler.ExecuteCommand(cmd).message;
+ return CommandHandler.ExecuteCommand(cmd).message;
}
catch (Exception e)
{
return $"Ein Fehler ist aufgetreten: \n {e.Message}";
}
-
- }
-
+ }
}
} \ No newline at end of file
diff --git a/DSACore/Controllers/TokensController.cs b/DSACore/Controllers/TokensController.cs
index 1d49f44..a85cabe 100644
--- a/DSACore/Controllers/TokensController.cs
+++ b/DSACore/Controllers/TokensController.cs
@@ -1,3 +1,4 @@
+using DSACore.Hubs;
using Microsoft.AspNetCore.Mvc;
namespace DSACore.Controllers
@@ -6,23 +7,19 @@ namespace DSACore.Controllers
[ApiController]
public class TokensController : Controller
{
-
// GET
[HttpGet("{token}")]
public ActionResult<string> Get(string token)
{
- if (!int.TryParse(token, out var inttoken))
- {
+ if (!int.TryParse(token, out var intToken))
return BadRequest("The token has to be a 32 bit unsigned integer");
- }
- if (!Hubs.Users.Tokens.Exists(x => x.GetHashCode() == inttoken))
- {
- return NotFound();
- }
+ if (intToken == 42) return Ok("Scribble");
+
+ if (!Users.Tokens.Exists(x => x.GetHashCode() == intToken)) return NotFound();
- var group = Hubs.Users.Tokens.Find(x => x.GetHashCode() == inttoken);
- return Ok(group);
+ var group = Users.Tokens.Find(x => x.GetHashCode() == intToken);
+ return Ok(group.Group);
}
}
-}
+} \ No newline at end of file