Created
December 4, 2018 12:19
-
-
Save safestudent/f84598f9f8b463da756892042c85d28c to your computer and use it in GitHub Desktop.
GetAveragePoints Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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