Skip to content

Conversation

@Muhammadou1
Copy link
Collaborator

  • User is able to create a task as a child task and link it to a ParentTaskId that already exists
  • User is able to edit a task that has no parent and associate it to a ParentTaskId
  • User is not able to mark a parent task as complete unless all its chid tasks are marked as complete

@JCruz6725 JCruz6725 linked an issue Nov 11, 2025 that may be closed by this pull request
public string Title { get; set; }
public DateTime? DueDate { get; set; }
public int Priority { get; set; }
public Guid ParentTaskId { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParentTaskId is optional.

public string Title { get; set; }
public DateTime? DueDate { get; set; }
public int Priority { get; set; }
public Guid ParentTaskId { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParentTaskId is optional.

@@ -1 +1 @@
using System;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert all changes to this file.


namespace Web.Api.Persistence.Repositories
{
public class TaskItemRepo
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert whitespace and new line changes in this file.

Comment on lines 126 to 136
if (taskCreatedDto.ParentTaskId != Guid.Empty)
{
SubTask subTask = new SubTask
{
TaskItemId = taskCreatedDto.ParentTaskId,
SubTaskItemId = taskCreation.Id,
CreatedDate = DateTime.Now,
CreatedUserId = userId
};
taskCreation.SubTaskSubTaskItems.Add(subTask);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move this before the first save changes call, you would not need to call save changes for a second time. refactor to so that it does a single call.

Title = taskCreation.Title,
DueDate = taskCreation.DueDate,
Priority = taskCreation.Priority,
ParentTaskId = taskCreation.SubTaskSubTaskItems?.FirstOrDefault()?.TaskItemId ?? Guid.Empty,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correcting the properties on the dto would fix this assignment mess.

Title = taskItem.Title,
DueDate = taskItem.DueDate,
Priority = taskItem.Priority,
ParentTaskId = taskItem.SubTaskSubTaskItems?.FirstOrDefault()?.TaskItemId ?? Guid.Empty,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correcting the Dto will fix this.

}

// Prevent completing a parent task when any child sub-task is not complete.
if (taskItem.SubTaskTaskItems != null)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to work. You're not looking beyond the immediate child.

Additionally, because you can link tasks at any point in their lifetime, you can mix pending and completed tasks in any order.

(1 complete) -> (2 pending) -> (3 pending) -> (4 complete) -> (5 pending)
....................................................................................................................... \ -> (6 pending)

If this were to happen, we would still need to ensure that we close them in sequence. That means if you try to complete 3, it should deny the user until 5 and 6 are closed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue we encountered has been fix. At any time where child task is found to be pending a parent task will not be allowed as complete

/// <param name="taskId"></param>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<TaskItem?> GetTaskByIdAsync(Guid taskId, Guid userId)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nay

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isnt going to work, this is not a broad enough view of all the data.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially with the recursive calls, because eventually the recursion will run out of data to process due to the original query.

@JCruz6725 JCruz6725 moved this from CodeReview to In Progress in @JCruz6725's TaskManager_WebAPI_Mj Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

SubTask

3 participants