using ReAct_PME.WPF_FrameWork;

namespace ReAct_PME.ViewModels
{
    public class ParametresCheckEmails_VM : BaseViewModel
    {
        public int SelectedItemInbox { get; set; }
        public int SelectedItemSent { get; set; }

        public ParametresCheckEmails_VM()
        {
            LoadData();
        }

        private bool LoadData()
        {
            try
            {
                (SelectedItemInbox, SelectedItemSent) = Services.EmailService.LoadParametresCheckEmail();
                return true;

            }
            catch
            {
                return false;
            }

        }

        public bool SaveData()
        {
            try
            {
                if (SelectedItemInbox < 0 || SelectedItemInbox > 1 || SelectedItemSent < 0 || SelectedItemSent > 1)
                {
                    SelectedItemInbox = 0; // Réinitialiser à 0 si la valeur est en dehors de l'intervalle
                    SelectedItemSent = 0;
                    return false;
                }
                return Services.EmailService.SaveParametresCheckEmail(SelectedItemInbox, SelectedItemSent);
            }
            catch
            {
                return false;
            }

        }
    }
}
