public HttpResponseMessage GetAllStudents(HttpRequestMessage request) { var students = _studentApi.GetAllStudents(); var studentsVm = StudentViewModel.MapMultipleStudents(students); foreach (var model in studentsVm) { var report = _studentApi.GetMostRecentReport(model.ID); model.InstitutionName = _studentApi.GetInstitution(model.InstitutionID).Name; model.ImagePath = _studentApi.GetUserInfo(model.ID).ProfilePicturePath; if (report != null) { model.AverageMark = report.Average; } } var response = request.CreateResponse(HttpStatusCode.OK, studentsVm); return(response); }