Authorizations
Some checks failed
Dotnet build and test / log-the-inputs (push) Failing after 2s
Dotnet build and test / build (push) Failing after 2s

This commit is contained in:
Paul Schneider
2025-08-18 11:27:13 +01:00
parent 541b891c3b
commit 1e568279ad
13 changed files with 34 additions and 28 deletions

View File

@ -50,9 +50,8 @@ namespace Yavsc.Controllers
private List<SelectListItem> GetEligibleParent(string code)
{
// eligibles are those
// who are not in descendants
// who are not in descendence
//
var acts = _context.Activities.Where(
a => a.Code != code
).Select(a => new SelectListItem
@ -68,13 +67,13 @@ namespace Yavsc.Controllers
var pi = acts.FirstOrDefault(i => i.Value == existing.ParentCode);
if (pi!=null) pi.Selected = true;
else nullItem.Selected = true;
RecFilterChild(acts, existing);
RecursivelyFilterChild(acts, existing);
return acts;
}
/// <summary>
/// Filters a activity selection list
/// in order to exculde any descendant
/// in order to exclude any descendant
/// from the eligible list at the <c>Parent</c> property.
/// WARN! results in a infinite loop when
/// data is corrupted and there is a circularity
@ -82,22 +81,19 @@ namespace Yavsc.Controllers
/// </summary>
/// <param name="list"></param>
/// <param name="activity"></param>
private static void RecFilterChild(List<SelectListItem> list, Activity activity)
private static void RecursivelyFilterChild(List<SelectListItem> list, Activity activity)
{
if (activity == null) return;
if (activity.Children == null) return;
if (list.Count == 0) return;
foreach (var child in activity.Children)
{
RecFilterChild(list, child);
RecursivelyFilterChild(list, child);
var rem = list.FirstOrDefault(i => i.Value == child.Code);
if (rem != null) list.Remove(rem);
}
}
// GET: Activity/Details/5
public IActionResult Details(string id)
{