예제 #1
0
        public HttpResponseMessage ApplyForSponsorship(HttpRequestMessage request,
                                                       StudentSponsorshipViewModel application)
        {
            var newApplication = new StudentSponsorship()
            {
                StudentId          = application.StudentId,
                SponsorshipId      = application.SponsorshipId,
                ApplicationDate    = application.ApplicationDate,
                SponsorshipOffered = application.SponsorshipOffered,
                Status             = application.Status
            };

            _studentApi.ApplyForSponsorship(newApplication);

            var sponsorship = _studentApi.GetSponsorship(newApplication.SponsorshipId);

            var sponsor = _sponsorApi.GetSponsor(sponsorship.SponsorId);

            sponsor.BursifyScore += 2;

            _sponsorApi.SaveSponsor(sponsor);

            var model = new StudentSponsorshipViewModel();

            var applicationVm = model.MapSIngleStudentSponsorship(newApplication);

            var response = request.CreateResponse(HttpStatusCode.Created, applicationVm);

            return(response);
        }
예제 #2
0
        public HttpResponseMessage ApproveSponsorship(HttpRequestMessage request, int studentId, int sponsorshipId)
        {
            bool status = _sponsorApi.ApproveSponsorship(studentId, sponsorshipId);

            var sponsorship = _studentApi.GetSponsorship(sponsorshipId);

            var sponsor = _sponsorApi.GetSponsor(sponsorship.SponsorId);

            sponsor.BursifyScore += 15;

            _sponsorApi.SaveSponsor(sponsor);

            HttpResponseMessage response = null;

            if (status)
            {
                response = request.CreateResponse(HttpStatusCode.OK, new { success = true });
            }
            else
            {
                response = request.CreateResponse(HttpStatusCode.OK, new { success = false });
            }

            return(response);
        }
예제 #3
0
        public HttpResponseMessage GetSponsorship(HttpRequestMessage request, int sponsorshipId)
        {
            var sponsorship = _studentApi.GetSponsorship(sponsorshipId);

            sponsorship.NumberOfViews += 1;
            _studentApi.SaveSponsorship(sponsorship);

            var model = new SponsorshipViewModel();

            var sponsorshipVm = model.SingleSponsorshipMap(sponsorship);

            sponsorshipVm.ApplicantCount     = _sponsorApi.GetStudentsApplying(sponsorshipVm.ID).Count;
            sponsorshipVm.SponsorPicturePath = _sponsorApi.GetUserInfo(sponsorshipVm.SponsorId).ProfilePicturePath;

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



            return(response);
        }