I am creating a score-tracking web application for my friends and I to use. The tracker have to group the scores based on how many rounds the player with the least amount of rounds have been playing.
Example: If I have played 6 rounds, and a friend of mine has only played 4, then all of his rounds would be counting in the tournament and only the 4 best of mine would be taken to account.
This is what I have so far:
[ActionName("List")]
public async Task<IActionResult> List()
{
var allData = await _cosmosDbService.GetScoresAsync(
"SELECT * FROM c");
var countRecordData = allData.GroupBy(l => l.Player).Select(cl => new Score
{
Player = cl.Count().ToString()
}).ToList();
var minRecord = countRecordData.Min(record => record.Player);
int minRecordInt = Int32.Parse(minRecord);
var sumData = allData.GroupBy(l => l.Player).Select(cl => new Score
{
Player = cl.First().Player,
Points = cl.Sum(c => c.Points),
Strokes = cl.Sum(c => c.Points),
}).ToList();
return View(sumData);
}
the minRecord is only used to get the player with least amount of records(number of least amount). I am not using it anywhere else.
Here is the Score model:
public class Score
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "Player")]
public string Player { get; set; }
[JsonProperty(PropertyName = "Course")]
public string Course { get; set; }
[JsonProperty(PropertyName = "Points")]
public int Points { get; set; }
[JsonProperty(PropertyName = "Strokes")]
public int Strokes { get; set; }
}
Does anyone know how I can reach this requirement?