57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
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: /<APIController>
|
|
[HttpGet]
|
|
public IEnumerable<String> Get()
|
|
{
|
|
List<String> 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 /<APIController>/5
|
|
[HttpGet("{id}")]
|
|
public string Get(int id)
|
|
{
|
|
return "value";
|
|
}
|
|
|
|
// POST /<APIController>
|
|
[HttpPost]
|
|
public void Post([FromBody] string value)
|
|
{
|
|
}
|
|
|
|
// PUT /<APIController>/5
|
|
[HttpPut("{id}")]
|
|
public void Put(int id, [FromBody] string value)
|
|
{
|
|
}
|
|
|
|
// DELETE /<APIController>/5
|
|
[HttpDelete("{id}")]
|
|
public void Delete(int id)
|
|
{
|
|
}
|
|
}
|
|
}
|