private void AddNodeFilho(TreeNode node)
 {
     foreach (TreeNode nodeitem in node.Nodes)
     {
         if (nodeitem.Checked)
         {
             var moduleId = Convert.ToInt32(nodeitem.Tag);
             var profileClass = new AppProfileClass { ProfileID = _profileId, ModuleID = moduleId };
             _db.InsertProfileClass(profileClass);
         }
         AddNodeFilho(nodeitem);
     }
 }
        private void UpdateProfile()
        {
            if (!ValidaProfile()) return;
            try
            {
                var profile = _db.GetProfileById(_profileId);
                profile.ProfileDescription = txtProfile.Text;

                _db.UpdateProfile(profile);

                _db.DeleteAllProfileClass(_profileId);

                foreach (TreeNode node in treeModulos.Nodes)
                {
                    if (node.Checked)
                    {
                        var moduleId = Convert.ToInt32(node.Tag);
                        var profileClass = new AppProfileClass { ProfileID = _profileId, ModuleID = moduleId };
                        _db.InsertProfileClass(profileClass);
                    }
                    AddNodeFilho(node);
                }

            }
            catch (EntityException ex)
            {
                MessageBox.Show(Resources.ERROR_UPDATE_PROFILE + ex.Message, Text, MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                cmdSalvar.Enabled = true;
                return;
            }
            _frmUtil.SetMessageError(ref tssStatus, true, "Perfil atualizado com sucesso!", AppFormUtil.StatusForm.Success);
            GetAllProfiles();
            ControlesPerfil(TypeTransaction.Clear);
        }
 public void InsertProfileClass(AppProfileClass profileClass)
 {
     _db.AppProfileClass.Add(profileClass);
     Commit();
 }