Esempio n. 1
0
        /// <summary>
        /// Method called on add user click event.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> sender of the event.</param>
        /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/>.</param>
        private void AddUser_Click(object sender, RoutedEventArgs e)
        {
            using (WindowFormUserLayout dlg = new WindowFormUserLayout())
            {
                bool?result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    MessageBoxs.IsBusy = true;
                    log.Warn("Adding or editing User informations. Please wait...");

                    UserEntityCollection.DbInsert(new List <UserEntity> {
                        dlg.NewForm
                    });

                    if (MainFrame?.Content?.GetType() == typeof(PageUsersLayout))
                    {
                        ((PageUsersLayout)MainFrame.Content).Model.Users.Items.Add(dlg.NewForm);
                    }

                    log.Warn("Adding or editing User informations. Done");
                    MessageBoxs.IsBusy = false;
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 public void AddUserNew(UserEntity item)
 {
     Users.Items.Add(item);
     UserEntityCollection.DbInsert(new List <UserEntity> {
         item
     });
     LoadAll();
 }
Esempio n. 3
0
        /// <summary>
        /// Method to delete a user from the list and the database.
        /// </summary>
        /// <param name="item">The User to remove from database.</param>
        public void DeleleUser(UserEntity item)
        {
            // Remove item from the database.
            UserEntityCollection.DbDelete(new List <UserEntity> {
                item
            });

            // Remove item from the list.
            Users.Items.Remove(item);

            //Refresh();
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        public void SaveUserChanges(UserEntity item)
        {
            UserEntity old   = Users.Items.Single(x => x.PrimaryKey == item.PrimaryKey);
            int        index = Users.Items.IndexOf(old);

            UserEntityCollection.DbUpdate(new List <UserEntity> {
                item
            }, new List <UserEntity> {
                old
            });;
            Users.Items[index] = item;

            //Refresh();
        }
Esempio n. 5
0
        /// <summary>
        /// Method to load the list of users from the database.
        /// </summary>
        public void LoadUsers()
        {
            MessageBoxs.IsBusy = true;
            log.Warn(MessageBoxs.BusyContent = "Loading Users list. Please wait...");

            try
            {
                UserOptionsList op = new UserOptionsList
                {
                    Dependencies = { EnumEntitiesDependencies.UsersInAclGroups }
                };

                if (((DataGridAclGroupsLayout)(ControlView.FindName("UcDataGridAclGroupsServerName")))?.SelectedItem is AclGroupEntity a && a.PrimaryKey > 0)
                {
                    op.IncludeAclGroupKeys = new List <int>()
                    {
                        a.PrimaryKey
                    };
                }

                UserEntityCollection users = new UserEntityCollection(op, false);
                users.Load();
                Users.Items = users;

                log.Info(MessageBoxs.BusyContent = "Loading Users list. Done.");
            }
            catch (Exception e)
            {
                MessageBoxs.BusyContent = "Loading Users list. failed !";
                log.Fatal(MessageBoxs.BusyContent, e);
                MessageBoxs.Fatal(e, (string)MessageBoxs.BusyContent);
            }
            finally
            {
                log.Warn(MessageBoxs.BusyContent = "Loading Users list. Done.");
                MessageBoxs.IsBusy = false;
            }
        }