private IEnumerable <Candidate> GetCandidates(IEnumerable <UserProfileInfo> profiles) { return(from profile in profiles let results = _exercisesResultsService.GetCandidateExercisesResults(profile.Id) let score = results.Sum(result => result.Score) let maxScore = results.Sum(result => result.CandidateExercise.MaximumScore) select new Candidate { Id = profile.Id, FirstName = profile.FirstName, LastName = profile.LastName, Score = score, MaximumScore = maxScore }); }
public IHttpActionResult GetCandidateExcerciseResults(Guid candidateId) { try { var results = _exercisesResultsService.GetCandidateExercisesResults(candidateId); if (results.Count() == 0) { return(NotFound()); } return(Ok(results)); } catch (Exception) { return(InternalServerError()); } }