Beispiel #1
0
        public int CreateProfileAccount(User user, Profile profile, string password)
        {
            var transaction = SessionData.Contains("Transaction") ? SessionData.Get<SqlTransaction>("Transaction") : null;
            var service = new LoginService();
            var encryptedPass = service.ComputeHash(password, new SHA256CryptoServiceProvider());
            int result = 0;
            if (transaction != null)
            {
                result = SqlDataAccess.ExecuteScalarQuery<int>(
                    "GRUPO_N.InsertProfileUser", SqlDataAccessArgs
                    .CreateWith("@UserName", user.UserName)
                    .And("@Password", encryptedPass)
                    .And("@ProfileName", profile.ToString())
                .Arguments, transaction);
            }
            else
            {
                result = SqlDataAccess.ExecuteScalarQuery<int>(ConfigurationManager.ConnectionStrings["GrouponConnectionString"].ToString(),
                    "GRUPO_N.InsertProfileUser", SqlDataAccessArgs
                    .CreateWith("@UserName", user.UserName)
                    .And("@Password", encryptedPass)
                    .And("@ProfileName", profile.ToString())
                .Arguments);
            }

            return result;
        }
Beispiel #2
0
        public int CreateAccount(User user, string password)
        {
            var service = new LoginService();
            var encryptedPass = service.ComputeHash(password, new SHA256CryptoServiceProvider());
            var result = SqlDataAccess.ExecuteScalarQuery<int>(ConfigurationManager.ConnectionStrings["GrouponConnectionString"].ToString(),
                "GRUPO_N.InsertUser", SqlDataAccessArgs
                .CreateWith("@UserName", user.UserName)
                .And("@Password", encryptedPass)
                .And("@ID_Rol", user.RoleID)
            .Arguments);

            return result;
        }
Beispiel #3
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (txtPassword.Text != txtConfirmPassword.Text)
     {
         MessageBox.Show("Las contraseñas no coinciden!");
         return;
     }
     var loginService = new LoginService();
     var success = loginService.UpdateUserPassword(Session.User, txtActual.Text, txtPassword.Text);
     if(success)
         MessageBox.Show("Contraseñas actualizada correctamente!");
     else
         MessageBox.Show("La contraseña actual ingresada no es correcta");
 }