/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDeleteTeam_Click(object sender, EventArgs e) { // Make the sure user selected a team if (ddlTeamsDelete.SelectedValue.Equals("") || ddlTeamsDelete.Equals("0") || ddlTeamsDelete.SelectedValue == null) { lblDeleteTeamResults.ForeColor = Color.Red; lblDeleteTeamResults.Text = "You must first select a team to delete. "; return; } // First make sure the current user is the admin of the selected team Team team = TeamDAL.GetTeamById(Convert.ToInt64(ddlTeamsDelete.SelectedValue)); lblDeleteTeamResults.Text = ""; // If the user is NOT the team admin... if (currentUser.ID != team.TeamOwner) { lblDeleteTeamResults.ForeColor = Color.Red; lblDeleteTeamResults.Text = "Cannot delete a team that you are not the admin of. "; return; } // Attempt to delete all information about the tasks associated with the team // to delete (task, task notes, and mappings to assigned users) List <Int64> listOfTasksToDelete = TaskDAL.GetAllTeamTasks(team.TeamID); foreach (Int64 taskID in listOfTasksToDelete) { TaskNotesDAL.DeleteAllTaskNotes(taskID); UserTasksDAL.DeleteAllTaskUsers(taskID); TaskDAL.DeleteTask(taskID); } // Atttempt to delete the team if (TeamDAL.DeleteTeam(team.TeamID) && TeamMemberDAL.RemoveAllMembers(team.TeamID)) { lblDeleteTeamResults.ForeColor = Color.Blue; lblDeleteTeamResults.Text = "Successfully deleted the team."; // Remember to update the drop down lists on the page ddlTeamsDelete.DataBind(); ddlTeamsView.DataBind(); ddlTeamsUpdate.DataBind(); ddlUpdateRemoveMember.DataBind(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDeleteTask_Click(object sender, EventArgs e) { if (ddlDeleteTeam.SelectedValue.Equals("") || ddlDeleteTeam.SelectedValue.Equals("0") || ddlDeleteTeam.SelectedValue == null || ddlDeleteTask.SelectedValue.Equals("") || ddlDeleteTask.SelectedValue.Equals("0") || ddlDeleteTask.SelectedValue == null) { lblDeleteTaskResults.ForeColor = Color.Red; lblDeleteTaskResults.Text = "You must first select a team and task to delete a task. "; return; } Task task = TaskDAL.GetTaskByID(Convert.ToInt64(ddlDeleteTask.SelectedValue)); Team taskTeam = TeamDAL.GetTeamById(task.TeamID); // First ensure that the current user, is the admin of the team that this task // is associated with if (currentUser.ID != taskTeam.TeamOwner) { lblDeleteTaskResults.ForeColor = Color.Red; lblDeleteTaskResults.Text = "Cannot delete a task of a team that you are not the admin of."; return; } // Delete the task and all of its notes and all of its mappings to users bool wasTaskDeletionSuccessful = TaskDAL.DeleteTask(task.TaskID); bool wasTaskNotesDeletionSuccessful = TaskNotesDAL.DeleteAllTaskNotes(task.TaskID); bool wasTaskUsersDeletionSuccessful = UserTasksDAL.DeleteAllTaskUsers(task.TaskID); // Signal whether the deletion was successful or not if (!wasTaskDeletionSuccessful || !wasTaskNotesDeletionSuccessful || !wasTaskUsersDeletionSuccessful) { lblDeleteTaskResults.ForeColor = Color.Red; lblDeleteTaskResults.Text = "Error occurred while deleting the task. "; return; } else { lblDeleteTaskResults.ForeColor = Color.Blue; lblDeleteTaskResults.Text = "Successfully delete the specified task. "; // Force all dropdown lists to refresh this.RefreshAllDropDownLists(); } }
public void DeleteTask(int id) { TaskDAL.DeleteTask(id); }
public void DeleteTask(int taskid) { int result1 = taskDal.DeleteTask(taskid); int result2 = locationDal.DeleteLocation(taskid); }
public void DeleteTask(int taskId) { TaskDAL taskDAL = new TaskDAL(); taskDAL.DeleteTask(taskId); }
public IActionResult DeleteConfirmed(int?id) { objtask.DeleteTask(id); return(RedirectToAction("Index")); }
public int DeleteTask(int id) { return(data.DeleteTask(id)); }
public void Delete() { TaskDAL.DeleteTask(this.ID); }