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

namespace adas_core.Domain.Models.DTO;

/// <summary>
/// Represents a data transfer object used to update a list of unit identifiers.
/// </summary>
public class UpdateUnitIdListDto
{
    public ObjectId UnitId { get; set; }

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

    /// <summary>
    /// Returns a string representation of the <see cref="UpdateUnitIdListDto"/> instance, including the formatted entries of its <c>MasterListData</c> collection.
    /// </summary>
    /// <returns>A string in the format <c>UpdateUnitIdListDto[...</c> containing the concatenated <c>MasterListData</c> values.</returns>
    public override string ToString()
        {
            List<string> items = [];
    
            items.AddRange(MasterListData.Select(masterListData => $", MasterListData: {masterListData}"));
    
    
            return "UpdateUnitIdListDto[" + string.Join(", ", items) + "]";
        }
}

/// <summary>
/// Represents a data container for a master list, serving as a centralized collection of items used for reference or aggregation purposes.
/// </summary>
public class MasterListData
{
    public ObjectId? MasterListId { get; set; }
    public MasterListType? MasterListType { get; set; }

    /// <summary>
    /// Returns a string representation of the master list, formatted with its identifier and type enclosed in square brackets.
    /// Handles null values for <c>MasterListId</c> and <c>MasterListType</c> by displaying them as "Null" and "null" respectively.
    /// </summary>
    /// <returns>A formatted string containing the identifier and type of the master list.</returns>
    public override string ToString()
        {
            List<string> items =
            [
                MasterListId != null ? $"identifier: {MasterListId.ToString()}" : "identifier: Null",
                MasterListType != null ? $"type: {MasterListType.ToString()}" : "type: null"
            ];
    
            return "[" + string.Join(", ", items) + "]";
        }
}