using Monitoring.Core.Domain.UserSettingsManagement;

namespace Monitoring.Models;

public class UserSettingsModel
{
    public Guid Id { get; init; }
    public Guid UserId { get; init; }
    public string PositioningStrategy { get; init; }
    public double? ManualLatitude { get; init; }
    public double? ManualLongitude { get; init; }
    public string? AssetGroupId { get; init; }
    public DateTime CreatedAt { get; init; }
    public DateTime UpdatedAt { get; init; }

    public UserSettingsModel()
    {
        PositioningStrategy = string.Empty;
    }

    public UserSettingsModel(
        Guid id, 
        Guid userId, 
        string positioningStrategy, 
        double? manualLatitude, 
        double? manualLongitude, 
        string? assetGroupId,
        DateTime createdAt,
        DateTime updatedAt)
    {
        Id = id;
        UserId = userId;
        PositioningStrategy = positioningStrategy;
        ManualLatitude = manualLatitude;
        ManualLongitude = manualLongitude;
        AssetGroupId = assetGroupId;
        CreatedAt = createdAt;
        UpdatedAt = updatedAt;
    }

    public static UserSettingsModel FromEntity(UserSettings entity) => new UserSettingsModel(
        entity.Id.Value,
        entity.UserId.Value,
        entity.PositioningStrategy.Value,
        entity.ManualPosition?.Latitude,
        entity.ManualPosition?.Longitude,
        entity.AssetGroupId?.Value.ToString(),
        entity.CreatedAt,
        entity.UpdatedAt
    );
} 