using BHServer.Data;
using Microsoft.AspNetCore.Mvc;
using BHServer.Models;
using Newtonsoft.Json;
namespace BHServer.Controllers
{
    [Route("api/[controller]")]
    public class ProvinceController(ApplicationDbContext db) : DBController(db)
    {
        // GET: api/<APIController>
        [HttpGet]
        public string Get()
        {
            List<Province> provinceList = DB.province.ToList();
            return JsonConvert.SerializeObject(provinceList);
        }

        // GET /<APIController>/5
        [HttpGet("{id}")]
        public string Get(int id)
        {
            var province = DB.province.ElementAt(id);
            return  JsonConvert.SerializeObject(province);
        }

        // POST /<APIController>
        [HttpPost]
        public void Post([FromBody] string value)
        {
            // TODO: Implement
        }

        // PUT /<APIController>/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] string value)
        {
            // TODO: Implement
        }

        // DELETE /<APIController>/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
            // TODO: Implement
        }
    }
}

