diff --git a/BHServer.csproj b/BHServer.csproj index 7813dbb..a4d4e22 100644 --- a/BHServer.csproj +++ b/BHServer.csproj @@ -11,6 +11,7 @@ + all diff --git a/Controllers/APIController.cs b/Controllers/APIController.cs new file mode 100644 index 0000000..22f91ed --- /dev/null +++ b/Controllers/APIController.cs @@ -0,0 +1,56 @@ +using BHServer.Data; +using Microsoft.AspNetCore.Mvc; + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace BHServer.Controllers +{ + [Route("[controller]")] + [ApiController] + public class APIController : ControllerBase + { + private readonly ApplicationDbContext _db; + public APIController(ApplicationDbContext db) + { + _db = db; + } + + // GET: / + [HttpGet] + public IEnumerable Get() + { + List arr = []; + foreach (var entry in _db.Provinces.ToList()) + { + String str = @"{""id"": " + entry.ProvinceId + @", ""name"": """ + entry.Name + @""", ""faction"": " + entry.Faction + @", ""mul"": " + entry.Multiplier + @", ""ats"": " + entry.ATs + @", ""state"": " + entry.State + "}"; + arr.Add(str); + } + return arr; + } + + // GET //5 + [HttpGet("{id}")] + public string Get(int id) + { + return "value"; + } + + // POST / + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT //5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE //5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +}