Beispiel #1
0
        private async void BtnValidate_Click(object sender, RoutedEventArgs e)
        {
            List <Role> userRoles = new List <Role>();

            foreach (object childStackPanel in this.userManagerView.stackpanelRoles.Children)
            {
                if (childStackPanel is StackPanel)
                {
                    foreach (object child in (childStackPanel as StackPanel).Children)
                    {
                        if (child is CheckBox)
                        {
                            if ((child as CheckBox).IsChecked == true)
                            {
                                Role role = roles.FirstOrDefault(x => x.Name == (child as CheckBox).Name.Replace("checkbox", ""));
                                if (role != null)
                                {
                                    userRoles.Add(role);
                                }
                            }
                        }
                    }
                }
            }
            this.userCreate.Roles = userRoles;
            await userManager.Insert(this.userCreate);

            MessageBox.Show("Data Inserted");
            UserManagerViewModel viewModel = new UserManagerViewModel();
        }
        private void BtnLogMe_Click(object sender, RoutedEventArgs e)
        {
            UserMySqlManager userManager = new UserMySqlManager();
            User             loggedUser  = userManager
                                           .GetByLogin(
                this.loginView.txtBoxLogin.Text,
                this.loginView.passwordBoxPassword.Password);

            if (loggedUser.Roles.Select(x => x.Name == "admin").FirstOrDefault())
            {
                UserManagerViewModel viewModel = new UserManagerViewModel();
            }
            else if (loggedUser.Roles.Select(x => x.Name == "wpf_user").FirstOrDefault())
            {
                DataInsertViewModel viewModel = new DataInsertViewModel(loggedUser);
            }
        }