using CommunityToolkit.Mvvm.DependencyInjection;
using PSCHelpdesk.Plugins.Nextcloud.Models;
using PSCHelpdesk.Shared.Service;
using PSCHelpdesk.Shared.Setting;
using PSCHelpdesk.Shared.ViewModels;

namespace PSCHelpdesk.Plugins.Nextcloud.ViewModels;

public class NextcloudSettingsViewModel: ViewModelBase, IViewModelBase
{
    private string _serverUrl;
    private string _userName;
    private string _appPassword;
    public NextcloudSettingsViewModel()
    {
        
        var settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
        var settings = new Settings();
        settingsManager.LoadPluginSettings("NextcloudSettings", settings);
        
        ServerUrl = settings.ServerUrl;
        Username = settings.Username;
        AppPassword = settings.AppPassword;
    }
    
    public string ServerUrl
    {
        get => _serverUrl;
        set => SetAndRaisePropertyChanged(ref _serverUrl, value);
    }
    public string Username
    {
        get => _userName;
        set => SetAndRaisePropertyChanged(ref _userName, value);
    }
    public string AppPassword
    {
        get => _appPassword;
        set => SetAndRaisePropertyChanged(ref _appPassword, value);
    }
}