[Route("api/[controller]")]
[ApiController]
public class RegionsController : ControllerBase
{
private readonly SkyblockRessourcesAPIContext _context;
public RegionsController(SkyblockRessourcesAPIContext context)
{
_context = context;
}
// GET: api/Regions/Get
[HttpGet]
[Route("Get")]
public async Task<ActionResult<IEnumerable<Region>>> GetRegion()
{
return await _context.Region.ToListAsync();
}
// POST: api/Regions/Post
[EnableCors("*", "*", "*")]
[HttpPost]
[Route("Post")]
public async Task<ActionResult<Region>> PostRegion([FromBody] Region region)
{
_context.Region.Add(region);
await _context.SaveChangesAsync();
return CreatedAtAction("GetRegion", new { id = region.Id }, region);
}
// DELETE: api/Regions/Delete
[HttpDelete]
[Route("Delete/all")]
public async Task<IActionResult> DeleteAllRegion()
{
var region = await _context.Region.ToListAsync();
if (region == null)
{
return NotFound();
}
_context.Region.RemoveRange(region);
return NoContent();
}
// DELETE: api/Regions/Delete?id=5
[HttpDelete]
[Route("Delete")]
public async Task<IActionResult> DeleteRegion(int id)
{
var region = await _context.Region.FindAsync(id);
if (region == null)
{
return NotFound();
}
_context.Region.Remove(region);
await _context.SaveChangesAsync();
return NoContent();
}
[Route("api/[controller]")]
[ApiController]
public class RegionsController : ControllerBase
{
private readonly SkyblockRessourcesAPIContext _context;
public RegionsController(SkyblockRessourcesAPIContext context)
{
_context = context;
}
// GET: api/Regions/Get
[HttpGet]
[Route("Get")]
public async Task<ActionResult<IEnumerable<Region>>> GetRegion()
{
return await _context.Region.ToListAsync();
}
// POST: api/Regions/Post
[EnableCors("*", "*", "*")]
[HttpPost]
[Route("Post")]
public async Task<ActionResult<Region>> PostRegion([FromBody] Region region)
{
_context.Region.Add(region);
await _context.SaveChangesAsync();
return CreatedAtAction("GetRegion", new { id = region.Id }, region);
}
// DELETE: api/Regions/Delete
[HttpDelete]
[Route("Delete/all")]
public async Task<IActionResult> DeleteAllRegion()
{
var region = await _context.Region.ToListAsync();
if (region == null)
{
return NotFound();
}
_context.Region.RemoveRange(region);
return NoContent();
}
// DELETE: api/Regions/Delete?id=5
[HttpDelete]
[Route("Delete")]
public async Task<IActionResult> DeleteRegion(int id)
{
var region = await _context.Region.FindAsync(id);
if (region == null)
{
return NotFound();
}
_context.Region.Remove(region);
await _context.SaveChangesAsync();
return NoContent();
}