24 lines
742 B
C#
24 lines
742 B
C#
#nullable enable
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace UserService.Infrastructure.DataModels
|
|
{
|
|
public abstract class Node : ICloneable
|
|
{
|
|
public int Id { get; set; }
|
|
[Required] public string CommonName { get; set; } = null!;
|
|
public string? Description { get; set; }
|
|
public ICollection<Node> Children { get; set; } = new List<Node>();
|
|
public Node? Parent { get; set; } //Parent
|
|
public int? ParentId { get; set; }
|
|
|
|
public override string ToString() => CommonName;
|
|
|
|
public int Level => Parent?.Level + 1 ?? 0;
|
|
|
|
/// <inheritdoc />
|
|
public virtual object Clone() => MemberwiseClone();
|
|
}
|
|
} |