protected void ActivityListGrid_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                string activityId      = (e.Item as GridDataItem).GetDataKeyValue("Id").ToString();
                var    projectId       = ProjectId.Value;
                var    projectDetailId = ProjectDetailId.Value;

                try
                {
                    DeleteProjectDetailActivityDTO deleteProjectDetailActivity = new DeleteProjectDetailActivityDTO()
                    {
                        ActivityProjectDetailId = Convert.ToInt64(activityId),
                        ProjectId       = Convert.ToInt64(ProjectId.Value),
                        ProjectDetailId = Convert.ToInt64(ProjectDetailId.Value)
                    };

                    ServiceResult <bool> serviceResult = new ServiceResult <bool>();
                    var queryString = new Dictionary <string, string>();
                    var response    = ApiHelper.CallSendApiMethod(ApiKeys.ProjectApiUrl, "DeleteProjectDetailActivity", queryString, deleteProjectDetailActivity);
                    if (!response.IsSuccessStatusCode)
                    {
                        throw new Exception("Hata oluştu!");
                    }
                    var data = response.Content.ReadAsStringAsync().Result;
                    serviceResult = JsonConvert.DeserializeObject <ServiceResult <bool> >(data);

                    if (serviceResult.ServiceResultType != EnumServiceResultType.Success)
                    {
                        throw new Exception(serviceResult.ErrorMessage);
                    }

                    labelErrorMessage.Text    = "Aktivite silindi.";
                    labelErrorMessage.Visible = true;
                    GetActivityList(Convert.ToInt64(projectId), Convert.ToInt64(projectDetailId));
                }
                catch (Exception ex)
                {
                    labelErrorMessage.Text    = ex.Message;
                    labelErrorMessage.Visible = true;
                }
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult DeleteProjectDetailActivity(DeleteProjectDetailActivityDTO 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.DeleteProjectDetailActivity(model);
                return(Ok(serviceResult));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }