summaryrefslogtreecommitdiff
path: root/DSACore/Controllers
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-05-16 01:10:10 +0200
committerDennis Kobert <d-kobert@web.de>2019-05-16 01:10:10 +0200
commit91fc989eea5ee16c2f000064b5c040a6fe6f23b9 (patch)
tree2cb29d1bc191cbba9aab216620a4a644b1f6d806 /DSACore/Controllers
parent6d988d13f7fc1652e2d041cfd1c4b40dce6a8adb (diff)
Implement tokens
Diffstat (limited to 'DSACore/Controllers')
-rw-r--r--DSACore/Controllers/CommandsController.cs4
-rw-r--r--DSACore/Controllers/LobbyController.cs32
-rw-r--r--DSACore/Controllers/TokensController.cs28
3 files changed, 62 insertions, 2 deletions
diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs
index 5f27f63..d35690c 100644
--- a/DSACore/Controllers/CommandsController.cs
+++ b/DSACore/Controllers/CommandsController.cs
@@ -10,14 +10,14 @@ using Microsoft.AspNetCore.Mvc;
namespace DSACore.Controllers
{
- [Route("api/[controller]")]
+ [Route("dsa/[controller]")]
public class CommandsController : Controller
{
// GET: api/<controller>
[HttpGet]
public string Get()
{
- return "Dies ist die supa dolle Web Api";
+ return "Usage: post the command to execute";
}
// GET api/<controller>/5
diff --git a/DSACore/Controllers/LobbyController.cs b/DSACore/Controllers/LobbyController.cs
new file mode 100644
index 0000000..a946184
--- /dev/null
+++ b/DSACore/Controllers/LobbyController.cs
@@ -0,0 +1,32 @@
+using DSACore.Models.Network;
+using System;
+using Microsoft.AspNetCore.Mvc;
+
+namespace DSACore.Controllers
+{
+ public class ScribbleController : Controller
+ {
+ [Route("[controller]")]
+ // GET: api/<controller>
+ [HttpGet]
+ public string Get()
+ {
+ return "Usage: get /tokens/{Token}";
+ }
+
+ [HttpPost]
+ public string Post([FromBody]Command cmd)
+ {
+ try
+ {
+ return Commands.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
new file mode 100644
index 0000000..453d477
--- /dev/null
+++ b/DSACore/Controllers/TokensController.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+
+namespace DSACore.Controllers
+{
+ [Route("lobby/[controller]")]
+ [ApiController]
+ public class TokensController : Controller
+ {
+
+ // GET
+ [HttpGet("{token}")]
+ public async Task<ActionResult<string>> Get(int token)
+ {
+
+ if (!Hubs.Users.Tokens.Exists(x => x.GetHashCode() == token))
+ {
+ return NotFound();
+ }
+
+ var group = Hubs.Users.Tokens.Find(x => x.GetHashCode() == token);
+ return Ok(group);
+ }
+ }
+} \ No newline at end of file