Esempio n. 1
0
        public HttpResponseMessage EndorseCampaign(HttpRequestMessage request, int userId, int campaignId)
        {
            var campaign = _studentApi.EndorseCampaign(userId, campaignId);

            var camp = _studentApi.GetSingleCampaign(campaignId);

            camp.NumberOfUpVotes += 1;
            _studentApi.SaveCampaign(camp);

            var user = _studentApi.GetUserInfo(userId);

            if (user.UserType.Equals("Sponsor", StringComparison.OrdinalIgnoreCase))
            {
                var sponsor = _studentApi.GetSponsor(user.ID);

                sponsor.BursifyScore += 1;

                _sponsorApi.SaveSponsor(sponsor);
            }

            var campaignVM = new CampaignViewModel();

            campaignVM.SingleCampaignMap(campaign);

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

            return(response);
        }
Esempio 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);
        }
        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);
        }