Projektdateien hinzufügen.
This commit is contained in:
parent
72ecb03642
commit
76fbb232a7
48 changed files with 3779 additions and 0 deletions
21
Controllers/ErrorController.cs
Normal file
21
Controllers/ErrorController.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace WebEMSim.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("error")]
|
||||
public class ErrorController : ControllerBase
|
||||
{
|
||||
[HttpGet("{statusCode}", Name = "HandleError")]
|
||||
public IActionResult Handle(int statusCode)
|
||||
{
|
||||
if (statusCode == 404)
|
||||
{
|
||||
var fallbackFile = Path.Combine(Environment.CurrentDirectory, "webem-ui/build/404.html");
|
||||
return PhysicalFile(fallbackFile, "text/html");
|
||||
}
|
||||
|
||||
return StatusCode(statusCode);
|
||||
}
|
||||
}
|
||||
}
|
78
Controllers/TournamentController.cs
Normal file
78
Controllers/TournamentController.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace WebEMSim.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class TournamentController : ControllerBase
|
||||
{
|
||||
// GET: api/<TournamentController>
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return Storage.Shared.ListTournaments();
|
||||
}
|
||||
|
||||
// GET api/<TournamentController>/5
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult Get(string id)
|
||||
{
|
||||
Tournament? tournament = Storage.Shared.GetTournament(id);
|
||||
|
||||
if(tournament == null)
|
||||
return NotFound();
|
||||
|
||||
return Ok(tournament);
|
||||
}
|
||||
|
||||
// POST api/<TournamentController>
|
||||
[HttpPost]
|
||||
public IActionResult Post(/*[FromBody] string value*/)
|
||||
{
|
||||
Tournament? newTournament = Storage.Shared.CreateTournament();
|
||||
|
||||
if(newTournament == null)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
|
||||
newTournament.PlayoutTournament(); // TODO: Remove this
|
||||
|
||||
return Ok(newTournament);
|
||||
}
|
||||
|
||||
// POST api/<TournamentController>/{id}/play
|
||||
[HttpPost("{id}/play")]
|
||||
public IActionResult Post(string id)
|
||||
{
|
||||
Tournament? tournament = Storage.Shared.GetTournament(id);
|
||||
|
||||
if (tournament == null)
|
||||
return NotFound();
|
||||
|
||||
if (tournament.HasPlayed == true)
|
||||
return BadRequest();
|
||||
|
||||
tournament.PlayoutTournament();
|
||||
|
||||
return Ok(tournament);
|
||||
}
|
||||
|
||||
// DELETE api/<TournamentController>/5
|
||||
[HttpDelete("{id}")]
|
||||
public IActionResult Delete(string id)
|
||||
{
|
||||
bool? success = Storage.Shared.DeleteTournament(id);
|
||||
|
||||
if (success == null)
|
||||
return NotFound();
|
||||
|
||||
if(success != true)
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue