protected void buttonAddActivity_Click(object sender, EventArgs e) { var projectId = ProjectId.Value; var projectDetailId = ProjectDetailId.Value; try { AddProjectDetailActivityDTO newProjectDetailActivity = new AddProjectDetailActivityDTO() { ActivityId = Convert.ToInt32(ActivityType.SelectedValue), ProjectId = Convert.ToInt64(ProjectId.Value), ProjectDetailId = Convert.ToInt64(ProjectDetailId.Value), VolunteerId = UserHelper.CurrentUser.Id, StatusId = (int)EnumActivityStatusType.Beklemede }; ServiceResult <long> serviceResult = new ServiceResult <long>(); var queryString = new Dictionary <string, string>(); var response = ApiHelper.CallSendApiMethod(ApiKeys.ProjectApiUrl, "AddNewProjectDetailActivity", queryString, newProjectDetailActivity); 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); } labelErrorMessage.Text = "Aktivite eklendi."; labelErrorMessage.Visible = true; GetActivityList(Convert.ToInt64(projectId), Convert.ToInt64(projectDetailId)); } catch (Exception ex) { labelErrorMessage.Text = ex.Message; labelErrorMessage.Visible = true; } }
public IHttpActionResult AddNewProjectDetailActivity(AddProjectDetailActivityDTO 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.AddNewProjectDetailActivity(model); return(Ok(serviceResult)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }