using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Scry.Core.Data;

namespace Scry.ViewModels;

public partial class SettingsViewModel : ObservableObject
{
    private readonly CardDatabase _database;

    [ObservableProperty]
    private int _cardCount;

    [ObservableProperty]
    private int _oracleCount;

    [ObservableProperty]
    private int _setCount;

    [ObservableProperty]
    private string? _statusMessage;

    public SettingsViewModel(CardDatabase database)
    {
        _database = database;
    }

    [RelayCommand]
    private async Task LoadAsync()
    {
        CardCount = await _database.GetCardCountAsync();
        OracleCount = await _database.GetOracleCountAsync();
        SetCount = await _database.GetSetCountAsync();
        StatusMessage = $"Database ready: {CardCount:N0} cards, {OracleCount:N0} oracles, {SetCount:N0} sets";
    }
}
