| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- namespace Domain.Entities.Common;
- public class NavMenuItem
- {
- public int ID { get; private set; }
- public string Label { get; private set; } = default!;
- public string Href { get; private set; } = default!;
- public int SortOrder { get; private set; } = 0;
- public bool IsVisible { get; private set; } = true;
- public DateTime UpdatedAt { get; private set; } = DateTime.UtcNow;
- public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
- private NavMenuItem() { }
- private NavMenuItem(string label, string href, int sortOrder, bool isVisible)
- {
- if (string.IsNullOrWhiteSpace(label))
- {
- throw new ArgumentException("Label is required.", nameof(label));
- }
- if (label.Length > 50)
- {
- throw new ArgumentOutOfRangeException(nameof(label));
- }
- if (string.IsNullOrWhiteSpace(href))
- {
- throw new ArgumentException("Href is required.", nameof(href));
- }
- if (href.Length > 200)
- {
- throw new ArgumentOutOfRangeException(nameof(href));
- }
- Label = label;
- Href = href;
- SortOrder = sortOrder;
- IsVisible = isVisible;
- }
- public static NavMenuItem Create(string label, string href, int sortOrder, bool isVisible)
- {
- return new(label, href, sortOrder, isVisible);
- }
- public void Update(string label, string href, int sortOrder, bool isVisible)
- {
- if (string.IsNullOrWhiteSpace(label))
- {
- throw new ArgumentException("Label is required.", nameof(label));
- }
- if (label.Length > 50)
- {
- throw new ArgumentOutOfRangeException(nameof(label));
- }
- if (string.IsNullOrWhiteSpace(href))
- {
- throw new ArgumentException("Href is required.", nameof(href));
- }
- if (href.Length > 200)
- {
- throw new ArgumentOutOfRangeException(nameof(href));
- }
- Label = label;
- Href = href;
- SortOrder = sortOrder;
- IsVisible = isVisible;
- UpdatedAt = DateTime.UtcNow;
- }
- public void SetVisible(bool isVisible)
- {
- IsVisible = isVisible;
- UpdatedAt = DateTime.UtcNow;
- }
- }
|