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);
        }
Beispiel #2
0
        public HttpResponseMessage GetSponsor(HttpRequestMessage request, int userId)
        {
            var sponsor = _studentApi.GetSponsor(userId);

            var model = new SponsorViewModel();

            var sponsorVm = model.SingleSponsorMap(sponsor);

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

            return(response);
        }
 private void SetUserName(BursifyUserViewModel userVm)
 {
     if (userVm.UserType.Equals("Student", System.StringComparison.OrdinalIgnoreCase))
     {
         var tempUser = _studentApi.GetStudent(userVm.ID);
         var fullName = tempUser.Firstname + " "
                        + tempUser.Surname;
         userVm.Name = fullName;
     }
     else
     {
         userVm.Name = _studentApi.GetSponsor(userVm.ID).CompanyName;
     }
 }