using Monitoring.Core.Domain.AssetManagement;
using Monitoring.Core.Domain.UserPrimitives;

namespace Monitoring.Core.Domain.UserLogManagement;

public class UserLog
{
	public UserLogId Id { get; } = default!;
	public User User { get; } = default!;
	public UserId UserId { get; } = default!;
	public DateTime CreatedAt { get; }
	public UserLogInformation Information { get; } = default!;
	public Asset Asset { get; } = default!;
	public AssetId AssetId { get; } = default!;

	public static UserLog Create(UserId userId, AssetId assetId, UserLogInformation information)
	{
		return new UserLog(
			new UserLogId(Guid.NewGuid()),
			userId,
			assetId,
			DateTime.UtcNow,
			information
		);
	}

	public static UserLog Create(UserId userId, AssetId assetId, UserLogInformation information, DateTime createdAt)
	{
		return new UserLog(
			new UserLogId(Guid.NewGuid()),
			userId,
			assetId,
			createdAt,
			information
		);
	}

	private UserLog(UserLogId id, UserId userId, AssetId assetId, DateTime createdAt, UserLogInformation information)
	{
		Id = id;
		UserId = userId;
		Information = information;
		CreatedAt = createdAt;
		AssetId = assetId;
	}

	// For EF Core
	protected UserLog() { }
}