Skip to content

Instantly share code, notes, and snippets.

@safestudent
Created December 4, 2018 12:19
Show Gist options
  • Save safestudent/f84598f9f8b463da756892042c85d28c to your computer and use it in GitHub Desktop.
Save safestudent/f84598f9f8b463da756892042c85d28c to your computer and use it in GitHub Desktop.
GetAveragePoints Method
public object GetAveragePoints(SprintTrackerWebContext context)
{
// Create an empty list to store the points.
List<int> points = new List<int>();
// Get the points from each sprint in the database and add them to the list.
context.Sprint.ToList().ForEach(x => points.Add(x.ActualPoints));
// Check to see if the `points` list has any data in it
if (points.Any())
{
// If it does, return the average
return points.Average();
}
else
{
// If it doesn't return 0.0
return 0.0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment