using ReAct_PME.WPF_FrameWork;
using Services.ReActAgent;
using Services.Whisper;

namespace ReAct_PME.ViewModels
{
    public class ParametresWhisper_VM : BaseViewModel
    {
        public ParametresWhisperService SelectedItem { get; set; } = new();

        public ParametresWhisper_VM()
        {
            LoadData();
        }

        private bool LoadData()
        {
            bool bReturn = false;
            try
            {
                var item = ReActAgent.LoadParametresWhisper();
                if (item != null)
                {
                    SelectedItem = (ParametresWhisperService)item;
                    bReturn = true;
                }


                return bReturn;

            }
            catch
            {
                return false;
            }

        }

        public bool SaveData()
        {
            try
            {
                SelectedItem.Whisper_URL = SelectedItem.Whisper_URL.Trim();
                if (!SelectedItem.Whisper_URL.StartsWith("http://") && !SelectedItem.Whisper_URL.StartsWith("https://"))
                    SelectedItem.Whisper_URL = "http://" + SelectedItem.Whisper_URL.Trim();

                return ReActAgent.SaveParametresWhisper(SelectedItem);
            }
            catch
            {
                return false;
            }

        }

    }
}
