using BHServer.Data; using BHServer.Models; using Microsoft.AspNetCore.Mvc; using System; namespace BHServer.Controllers { public class ProvinceController : Controller { private readonly ApplicationDbContext _db; public ProvinceController(ApplicationDbContext db) { _db = db; } public IActionResult Index() { List ObjectProvinceList = _db.Provinces.ToList(); // If the above line faulters then ensure SQL Server is running return View(ObjectProvinceList); } [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) { var entry = _db.Provinces.ElementAt(id); String str = @"{""id"": " + entry.ProvinceId + @", ""name"": """ + entry.Name + @""", ""faction"": " + entry.Faction + @", ""mul"": " + entry.Multiplier + @", ""ats"": " + entry.ATs + @", ""state"": " + entry.State + "}"; return str; } // POST / [HttpPost] public void Post([FromBody] string value) { // TODO: Implement } // PUT //5 [HttpPut("{id}")] public void Put(int id, [FromBody] string value) { // TODO: Implement } // DELETE //5 [HttpDelete("{id}")] public void Delete(int id) { // TODO: Implement } } }