using adas_core.Domain.Enums;
using MongoDB.Bson;

namespace adas_core.Domain.Models.MongoModels;

/// <summary>
/// Represents a section, typically used to group or encapsulate a distinct portion of related content or functionality within a larger structure.
/// </summary>
public class Section
{
    // ReSharper disable once InconsistentNaming
    public ObjectId _id { get; set; }

    public string Id { get; set; } = string.Empty;


    public string? SectionTitle { get; set; }


    public string? PointOfCare { get; set; }


    public DateTime? LastUpdate { get; set; }

    public Dictionary<string, object> Configuration { get; set; } = [];

    public SectionConfig? SectionConfig { get; set; }
    public UiFontData? DesignProperties { get; set; }

    public Dictionary<string, List<PointOfCare>> PointOfCareList { get; set; } = new();

    public List<SectionItem> Items { get; set; } = [];

    public StatusEnum.Type? Status { get; set; } = null;

    /// <summary>
    /// Determines whether the current <see cref="Section"/> is equal to another <see cref="Section"/> by comparing their identifiers.
    /// Returns <c>false</c> when the supplied instance is <c>null</c>, so no exception is raised for null inputs.
    /// </summary>
    /// <param name="other">The <see cref="Section"/> instance to compare with the current one.</param>
    /// <returns><c>true</c> if both sections share the same <see cref="Section.Id"/>; otherwise, <c>false</c>.</returns>
    public bool Equals(Section? other)
        {
            return other != null &&
                   Id == other.Id;
        }

    /// <summary>
    /// Returns a string representation of the Section, including its identifier.
    /// </summary>
    /// <returns>A string formatted as "[Section id: {Id}]" containing the section's identifier.</returns>
    public override string ToString()
        {
            return "[Section id: " + Id + "]";
        }

    /// <summary>
    /// Represents an individual item within a section, encapsulating the data and behavior associated with that entry.
    /// </summary>
    public class SectionItem
    {
        public string? Group { get; set; }
        public List<Box> Boxes { get; set; } = [];
    }
}