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