'Build a one page nested parent-child organizational structure

I need to create this kind of organizational structure using .Net MVC, vanilla JS and jQuery Every parent and it's children can be modified, deleted, and you also should be able to add new ones. I think using one model should be enough? Because that model will represent both parent and child, because a parent can be a child as well. And then your usual CRUD operations, although I am not sure what I'll be passing to the controller to create a child for a chosen parent.

How I imagine it to look

    public class Entity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }

    public IList<Entity> Chidren { get; set; }
}

Or should the model look like this?

    public class Entity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }

    public int ParentId { get; set; } 
    public Entity Parent { get; set; }
}

Anything else I should think about?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source