protected void updateButton_Click(object sender, EventArgs e)
    {
        bool message = false;

        if (!CheckInputValues())
        {
            return;
        }

        Project projectObj = new Project();

        projectObj.ID           = projectIdDropDownList.Text;
        projectObj.Title        = titleTextBox.Text;
        projectObj.Description  = descriptionTextBox.Text;
        projectObj.StartDate    = Convert.ToDateTime(startDateTextBox.Text);
        projectObj.EstimateTime = Convert.ToDateTime(estimateDateTextBox.Text);
        projectObj.ClientId     = clientNameDropDownList.SelectedValue;
        //projectObj.Employee_Id = assignedToDropDownList.Text;
        projectObj.Status = projectStatusLabel.Text;


        try
        {
            ProjectGateway ProjectGatewayObject = new ProjectGateway();
            message           = ProjectGatewayObject.UpdateProject(projectObj);
            successLabel.Text = message.ToString();
            errorLabel.Text   = "";
        }
        catch (SqlException sqlExceptionObj)
        {
            errorLabel.Text = sqlExceptionObj.Message;
        }
        catch (Exception exceptionObj)
        {
            errorLabel.Text = exceptionObj.Message;
        }
        successLabel.Text = message.ToString();

        if (successLabel.Text == "True")
        {
            errorLabel.Text   = "";
            successLabel.Text = "Project details has been updated";
        }
        else
        {
            successLabel.Text = "";
            errorLabel.Text   = "Project details has not been updated";
        }

        LoadProjectData();
    }
示例#2
0
        public async Task <IActionResult> UpdateProject([FromBody] UpdateProjectViewModel model)
        {
            EnumProjectAccessRight projectAccessRight = await _getAccessUser.GetUserAccessRightProject(Convert.ToInt32(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)), model.Id);

            if (!HttpContext.User.IsInRole("admin") && projectAccessRight != EnumProjectAccessRight.Admin)
            {
                return(StatusCode(403, "Access Denied !"));
            }

            Result result = await _projectGateway.UpdateProject(model.Id, model.Name, model.Description, model.IsPublic);

            if (result.ErrorMessage == "Project with this id not exists")
            {
                return(BadRequest(result.ErrorMessage));
            }
            if (result.ErrorMessage == "Project with this name already exists")
            {
                return(BadRequest(result.ErrorMessage));
            }

            return(Ok("Project has been updated"));
        }