Skip to content

Commit

Permalink
fix: Remove tasks when unassigning developers
Browse files Browse the repository at this point in the history
  • Loading branch information
NexusrexDev committed May 7, 2024
1 parent 51e05be commit 7350a29
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Controllers/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public async Task<IActionResult> RemoveDeveloperFromProject(int id, string devel
var project = await _projectRepository.GetByIdIncludeAsync(criteria,
p => p.TeamLeader,
p => p.RequestedDevelopers,
p => p.AssignedDevelopers);
p => p.AssignedDevelopers,
p => p.Tasks);
if (project == null)
{
return NotFound();
Expand All @@ -217,6 +218,14 @@ public async Task<IActionResult> RemoveDeveloperFromProject(int id, string devel
else if (project.AssignedDevelopers.Contains(developer))
{
project.AssignedDevelopers.Remove(developer);

foreach (var task in project.Tasks)
{
if (task.AssignedDevId == developer.Id)
{
project.Tasks.Remove(task);
}
}
}
else
{
Expand Down
15 changes: 15 additions & 0 deletions Controllers/ProjectTaskController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ public async Task<IActionResult> UploadAttachment(int id, [FromForm] IFormFile f

}

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteProjectTask(int id)
{
var projectTask = await _projectTaskRepository.GetByIdAsync(id);
if (projectTask == null)
{
return NotFound();
}

await _projectTaskRepository.DeleteAsync(projectTask);
await _projectTaskRepository.Save();

return Ok("Task deleted successfully");
}


[HttpGet("{id}/AttachmentFile")]
public async Task<IActionResult> GetAttachmentFile(int id){
Expand Down

0 comments on commit 7350a29

Please sign in to comment.