示例#1
0
        public HttpResponseMessage SaveContactDetails(HttpRequestMessage request, ContactDetails details)
        {
            var user    = _studentApi.GetUserInfo(details.StudentId);
            var student = _studentApi.GetStudent(details.StudentId);
            var address = _studentApi.GetAddress(details.StudentId, details.AddressType);

            user.CellphoneNumber = details.CellphoneNumber;
            user.Email           = details.Email;

            student.GuardianPhone        = details.GuardianPhoneNumber;
            student.GuardianRelationship = details.GuardianRelationship;
            student.GuardianEmail        = details.GuardianEmail;

            address.StreetAddress = details.StreetAddress;
            address.City          = details.City;
            address.Province      = details.Province;
            address.PostalCode    = details.PostalCode;

            _studentApi.UpdateUser(user);
            _studentApi.SaveStudent(student);
            _studentApi.SaveAddress(address);

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

            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);
        }
示例#3
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);
        }