示例#1
0
        /// <summary>
        /// Legt einen neuen User in der Datenbank an
        /// </summary>
        /// <param name="name">User Name</param>
        /// <param name="password">User Password</param>
        /// <returns>Einen HttpStatusCode OK bei Erfolg InternalServerError bei Fehlschlag</returns>
        public HttpStatusCode Anlegen(string name, string password)
        {
            var con = DbHelper.GetDbConnection();

            con.Open();

            if (string.IsNullOrWhiteSpace(UserAccess.GetName(con, name)))
            {
                var HashnSalt = SaltHashHelper.CreateHash(password);
                UserAccess.AddUser(con, name, HashnSalt.Item1);
                UserAccess.AddSalt(con, UserAccess.GetIdByName(con, name), HashnSalt.Item2);
                return(HttpStatusCode.OK);
            }
            else
            {
                return(HttpStatusCode.InternalServerError);
            }
        }
示例#2
0
        public void UserAnlegen()
        {
            var con = DbHelper.GetDbConnection();

            con.Open();
            if (string.IsNullOrEmpty(UserAccess.GetName(con, "Test")))
            {
                var SaltnHash = SaltHashHelper.CreateHash("Test");
                UserAccess.AddUser(con, "Test", SaltnHash.Item1);
                var ID = UserAccess.GetIdByName(con, "Test");
                UserAccess.AddSalt(con, ID, SaltnHash.Item2);
            }
            else
            {
                Console.Write("Error");
            }
            con.Close();
        }