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.
 
 
 
 
 

37 lines
845 B

using RankingApp.Data.Models;
namespace RankingApp.Data.Services
{
public class RankingService
{
private ApplicationDbContext _context;
public RankingService(ApplicationDbContext context)
{
_context = context;
}
// Create
public Task<GameResult> AddGameResult(GameResult gameResult)
{
_context.GameResults.Add(gameResult);
_context.SaveChanges();
return Task.FromResult(gameResult);
}
// Read
public Task<List<GameResult>> GetGameResultsAsync()
{
List<GameResult> results = _context.GameResults
.OrderByDescending(item => item.Score)
.ToList();
return Task.FromResult(results);
}
// Update
// Delete
}
}