示例#1
0
        public HttpResponseMessage GetMostRecentReport(HttpRequestMessage request, int studentId)
        {
            var report = _studentApi.GetMostRecentReport(studentId);

            var reportVm = (new StudentReportViewModel()).MapSingleReport(report);

            var response = request.CreateResponse(HttpStatusCode.OK, reportVm);

            return(response);
        }
示例#2
0
        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);
        }
        public HttpResponseMessage GetApplicants(HttpRequestMessage request, int sponsorshipId)
        {
            var students = _sponsorApi.GetStudentsApplying(sponsorshipId);

            var data = students.Select(applicant =>
                                       new Applicant(applicant.ID, applicant.Firstname,
                                                     applicant.Surname,
                                                     _studentApi.GetInstitution(applicant.InstitutionID).Name,
                                                     _studentApi.GetUserInfo(applicant.ID).ProfilePicturePath,
                                                     applicant.Age,
                                                     _studentApi.GetAddress(applicant.ID, "Residential").Province,
                                                     applicant.EducationLevel,
                                                     _studentApi.GetMostRecentReport(applicant.ID).Average,
                                                     applicant.Gender)).ToList();

            var response = request.CreateResponse(HttpStatusCode.OK, new { count = data.Count, data });

            return(response);
        }
示例#4
0
        public HttpResponseMessage GetStudentsSponsored(HttpRequestMessage request, int sponsorshipId)
        {
            var students = _sponsorApi.GetStudentsSponsored(sponsorshipId);

            var s = StudentViewModel.MapMultipleStudents(students);

            foreach (var current in s)
            {
                var report  = _studentApi.GetMostRecentReport(current.ID);
                var address = _studentApi.GetAddress(current.ID, "Residential");

                current.Average  = report.Average;
                current.School   = report.ReportInstitution;
                current.Province = address.Province;
            }

            var response = request.CreateResponse(HttpStatusCode.OK, s);

            return(response);
        }