You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.0 KiB

2 years ago
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SharedData.Models;
using WebAPI.Data;
namespace WebAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RankingController : ControllerBase
{
private ApplicationDbContext _context;
public RankingController(ApplicationDbContext context)
{
_context = context;
}
// Create
// POST
// Read
// GET
[HttpGet]
public List<GameResult> GetGameResults()
{
List<GameResult> results = _context.GameResults
.OrderByDescending(x => x.Score)
.ToList();
return results;
}
[HttpGet("{id}")]
public GameResult GetGameResults(int id)
{
GameResult result = _context.GameResults
.Where(x => x.Id == id)
.FirstOrDefault();
return result;
}
// Update
// PUT
// Delete
// DELETE
}
}