using Services;
using ReAct_PME.WPF_FrameWork;

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

        public ParametresCompteMail_VM()
        {
            LoadData();
        }

        private bool LoadData()
        {
            bool bReturn = false;
            try
            {
                var item = Services.EmailService.LoadParametres();
                if(item != null)
                {
                    SelectedItem = (CompteMailUser)item;
                    bReturn = true;
                }


                return bReturn;
            
            }
            catch 
            {
                return false;
            }

        }

        public bool SaveData()
        {
            try
            {
                return Services.EmailService.SaveParametres(SelectedItem);
            }
            catch
            {
                return false;
            }

        }

    }
}
