/// <summary> /// this method is used to Delete Project into database /// </summary> /// <param name="id">Id of the project</param> /// <returns>Soft deletes the project </returns> public async Task <Project> DeleteProjectAsync(Guid projectId) { var sameProject = await _projectRepository.GetProjectByIdAsync(projectId); if (sameProject == null) { throw new Exception("Project does not exist."); } sameProject.IsDeleted = true; sameProject.EndDate = DateTime.UtcNow; var employeeList = await _projectManagementService.GetProjectMembers(projectId); foreach (var employee in employeeList) { await _projectManagementService.RemoveEmployeeFromProject(projectId, employee.Id); } await _projectRepository.SaveChangesAsync(); return(sameProject); }
public async Task <ActionResult> RemoveEmployeeFromProject(Guid projectId, Guid employeeId) { var result = await _projectManagementService.RemoveEmployeeFromProject(projectId, employeeId); return(Ok("Employee deleted from project.")); }