diff --git a/Controllers/ProjectController.cs b/Controllers/ProjectController.cs index 1a32562..bee23db 100644 --- a/Controllers/ProjectController.cs +++ b/Controllers/ProjectController.cs @@ -199,7 +199,8 @@ public async Task 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(); @@ -217,6 +218,14 @@ public async Task 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 { diff --git a/Controllers/ProjectTaskController.cs b/Controllers/ProjectTaskController.cs index adb625c..8a15403 100644 --- a/Controllers/ProjectTaskController.cs +++ b/Controllers/ProjectTaskController.cs @@ -210,6 +210,21 @@ public async Task UploadAttachment(int id, [FromForm] IFormFile f } + [HttpDelete("{id}")] + public async Task 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 GetAttachmentFile(int id){