using projet.bddmanager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace projet.dal
{
    /// <summary>
    /// Singleton pour l'accès à la base de données.
    /// </summary>
    public class Access
    {
        private static readonly string connectionString = "server=localhost;user id=mediatek;password=motDePasseFort;database=mediatek;";
        private static Access instance = null;

        /// <summary>
        /// Gère l'accès à la base de données via BddManager.
        /// </summary>
        public BddManager Manager { get; }

        private Access()
        {
            try
            {
                Manager = BddManager.GetInstance(connectionString);
            }
            catch (Exception)
            {
                Environment.Exit(0);
            }
        }
        /// <summary>
        /// Renvoie l'instance unique de la classe Access.
        /// </summary>
        /// <returns>Singleton de la connexion</returns>
        public static Access GetInstance()
        {
            if (instance == null)
            {
                instance = new Access();
            }
            return instance;
        }
    }
}
