Multiworld
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
using ALttPRandomizer.Settings;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class SeedController : Controller {
|
||||
@@ -32,6 +33,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
[Route("/multiworld")]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> GenerateMultiworld([FromBody] IList<SeedSettings> settings) {
|
||||
if (!ModelState.IsValid) {
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
try {
|
||||
var id = await this.RandomizeService.RandomizeMultiworld(settings);
|
||||
var url = string.Format("/multi/{0}", id);
|
||||
return Accepted(url, id);
|
||||
} catch (InvalidSettingsException ex) {
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("/seed/{id}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetSeed(string id) {
|
||||
@@ -50,5 +66,24 @@
|
||||
this.Logger.LogWarning("Unexpected result from SeedService: {@result}", result);
|
||||
return StatusCode(500);
|
||||
}
|
||||
|
||||
[Route("/multi/{id}")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetMulti(string id) {
|
||||
var result = await this.SeedService.GetMulti(id);
|
||||
if (result.TryGetValue("status", out var responseCode)) {
|
||||
switch (responseCode) {
|
||||
case 200:
|
||||
return Ok(result);
|
||||
case 404:
|
||||
return NotFound(result);
|
||||
case 409:
|
||||
return Conflict(result);
|
||||
}
|
||||
}
|
||||
|
||||
this.Logger.LogWarning("Unexpected result from SeedService: {@result}", result);
|
||||
return StatusCode(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user