Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 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);
        }