protected void RateVolunteer_Rate(object sender, EventArgs e) { RadRating oRating = (RadRating)sender; int activityId = Convert.ToInt32(oRating.DataModelID); long volunteerId = Convert.ToInt64(oRating.AccessKey); long projectDetailId = Convert.ToInt64(ProjectDetailName.SelectedValue); long userId = UserHelper.CurrentUser.UserId; short vote = Convert.ToInt16(oRating.Value); var newAddVolunteerVoteDTO = new AddVolunteerVoteDTO { ProjectDetailId = projectDetailId, UserId = userId, VolunteerId = volunteerId, ActivityId = activityId, Vote = vote }; try { ServiceResult <long> serviceResult = new ServiceResult <long>(); var queryString = new Dictionary <string, string>(); var response = ApiHelper.CallSendApiMethod(ApiKeys.ProjectApiUrl, "AddNewVolunteerVote", queryString, newAddVolunteerVoteDTO); if (!response.IsSuccessStatusCode) { throw new Exception("Hata oluştu!"); } var data = response.Content.ReadAsStringAsync().Result; serviceResult = JsonConvert.DeserializeObject <ServiceResult <long> >(data); if (serviceResult.ServiceResultType != EnumServiceResultType.Success) { throw new Exception(serviceResult.ErrorMessage); } GetVolunteerEvaluationList(); } catch (Exception ex) { } }
public IHttpActionResult AddNewVolunteerVote(AddVolunteerVoteDTO model) { if (!Request.Headers.Contains("apiKey")) { return(Unauthorized()); } string apiKey = Request.Headers.GetValues("apiKey").First(); if (!ApiHelper.CheckKey(apiKey)) { return(Unauthorized()); } try { var serviceResult = _projectService.AddNewVolunteerVote(model); return(Ok(serviceResult)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }