Exemplo n.º 1
0
        public static void InscriptionTherapeute(string nom, string prenom, string login, string pass, bool isAdmin)
        {
            //permet au TU de donner la fausse BD
            if (conn == null)
            {
                bdd = new ReaPlanDBEntities();
            }
            else
            {
                bdd = new ReaPlanDBEntities(conn);
            }

            nom = nom.ToUpper();
            using (bdd)
            {
                //Cryptage du mot de passe
                if (pass != null)
                {
                    string       passwordTmp   = login.ToLower() + pass;
                    UTF8Encoding textConverter = new UTF8Encoding();
                    byte[]       passBytes     = textConverter.GetBytes(passwordTmp);
                    pass = Convert.ToBase64String(new SHA384Managed().ComputeHash(passBytes));
                }

                TherapeuteDB thera = TherapeuteDB.CreateTherapeuteDB(nom, prenom, login, pass);
                if (isAdmin == true)
                {
                    thera.Administrateur = true;
                }
                bdd.AddToTherapeuteDBs(thera);
                bdd.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public void Init()
        {
            EntityConnection connection = Effort.EntityConnectionFactory.CreateTransient("name=ReaPlanDBEntities");

            context = new ReaPlanDBEntities(connection);

            //creation d'un faux therapeute adminstrateur
            pass  = "******";// = admin
            thera = TherapeuteDB.CreateTherapeuteDB("pedro", "drope", "admin", pass);
            thera.Administrateur = true;
            context.AddToTherapeuteDBs(thera);

            //creation d'un faux therapeute non adminstrateur
            pass  = "******";// = 123456
            thera = TherapeuteDB.CreateTherapeuteDB("jacko", "michel", "jackmich", pass);
            thera.Administrateur = false;
            context.AddToTherapeuteDBs(thera);

            context.SaveChanges();
            AdminData.conn = connection;
        }