parent id fix

This commit is contained in:
2026-03-02 17:24:47 -08:00
parent 55d2c42376
commit 231bdab223
9 changed files with 72 additions and 8 deletions
+24
View File
@@ -163,6 +163,30 @@ public class StudentController : BaseController
});
}
if (dto.GoalParentId.HasValue)
{
var summary = await _studentRepository.GetGoalSummaryAsync(idStudent);
var parentGoal = summary?.Goals.FirstOrDefault(g => g.GoalId == dto.GoalParentId.Value);
if (parentGoal is null)
{
return BadRequest(new ResponseResult<StudentGoalItem>
{
Success = false,
Message = "Parent goal not found."
});
}
if (parentGoal.GoalParentId.HasValue)
{
return BadRequest(new ResponseResult<StudentGoalItem>
{
Success = false,
Message = "The selected parent goal already has a parent."
});
}
}
var created = await _studentRepository.InsertGoalAsync(idStudent, userId, dto);
if (created is null)
{
@@ -5,4 +5,5 @@ public class CreateGoalDto
public string? Title { get; set; }
public string? Description { get; set; }
public string? Category { get; set; }
public Guid? GoalParentId { get; set; }
}
@@ -110,6 +110,7 @@ public class StudentRepository
new
{
p_id_goal = newGoalId.ToString(),
p_id_goal_parent = dto.GoalParentId?.ToString(),
p_id_student = idStudent.ToString(),
p_id_user = userId.ToString(),
p_title = dto.Title,