using System.Linq.Expressions;

using Monitoring.Core.Domain.UserLogManagement;

namespace Monitoring.Models;

public class UserLogModel
{
    public Guid Id { get; init; }
    public Guid AssetId { get; init; }
    public DateTime CreatedAt { get; init; }
    public string Information { get; init; }
    public Guid UserId { get; init; }
    public string Username { get; init; }

    public UserLogModel() {
        Information = string.Empty;
        Username = string.Empty;
    }

    public UserLogModel(Guid id, Guid assetId, DateTime createdAt, string information, Guid userId, string username)
    {
        Id = id;
        AssetId = assetId;
        CreatedAt = createdAt;
        Information = information;
        UserId = userId;
        Username = username;
    }

    public static Expression<Func<UserLog, UserLogModel>> FromEntity => entity => new UserLogModel(
        entity.Id.Value,
        entity.AssetId.Value,
        entity.CreatedAt,
        entity.Information,
        entity.User.Id.Value,
        entity.User.Username.Value
    );
}