Esempio n. 1
0
        private async void DeleteExtension()
        {
            SecurityFunctions.CheckForAccess(SecurityGroups.Delete);

            var result = (bool)await UserPrompts.PopupDialog(this, "Are you sure you want to delete this extension?", "Delete Extension", DialogButtons.YesNo);

            if (!result)
            {
                return;
            }

            var ctx = (Extension)this.DataContext;

            using (new WaitSpinner(this, "Deleting extension...", 150))
            {
                try
                {
                    await ctx.DeleteFromDatabaseAsync();
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    ExceptionHandler.MySqlException(this, ex);

                    return;
                }
            }

            await UserPrompts.PopupDialog(this, string.Format("Extension '{0}' deleted!", extensionContext.Number), "Success", DialogButtons.Default);

            OnExtensionDeleted(extensionContext);
            ((Extension)DataContext).Dispose();
            extensionContext.Dispose();
            this.Close();
        }
Esempio n. 2
0
        private async void AddExtension()
        {
            SecurityFunctions.CheckForAccess(SecurityGroups.Add);

            if (!FieldsValid(this))
            {
                return;
            }

            using (new WaitSpinner(this, "Adding extension...", 150))
            {
                try
                {
                    await extensionContext.InsertAsync();
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    ExceptionHandler.MySqlException(this, ex);

                    return;
                }

                this.DataContext = await extensionContext.FromDatabaseAsync();

                InputEnabled = false;
            }

            UserPrompts.PopupMessage(this, "Extension added.", "Success!");
        }
Esempio n. 3
0
        private async void UpdateExtension()
        {
            SecurityFunctions.CheckForAccess(SecurityGroups.Modify);

            if (!FieldsValid(this))
            {
                return;
            }

            using (var spinner = new WaitSpinner(this, "Updating extension...", 150))
            {
                var ctx = (Extension)this.DataContext;

                try
                {
                    await ctx.UpdateAsync();
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    ExceptionHandler.MySqlException(this, ex);

                    return;
                }

                // Copy new values to the original context to update the main window values.
                this.extensionContext.CopyValues(ctx);
            }

            UserPrompts.PopupMessage(this, "Extension updated.", "Success!");
        }
Esempio n. 4
0
        private async void EditExtension(Extension extension)
        {
            if (extension == null)
            {
                return;
            }

            SecurityFunctions.CheckForAccess(SecurityGroups.Modify);

            Extension remoteExtension;

            using (new WaitSpinner(this, "Loading extension...", 150))
            {
                try
                {
                    remoteExtension = (Extension)await extension.FromDatabaseAsync();
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    ExceptionHandler.MySqlException(this, ex);

                    return;
                }
            }

            var editWindow = new EditWindow(extension, remoteExtension);

            editWindow.ExtensionDeleted -= EditWindow_ExtensionDeleted;
            editWindow.ExtensionDeleted += EditWindow_ExtensionDeleted;
            editWindow.ShowDialog();
        }
Esempio n. 5
0
        private void NewExtension()
        {
            SecurityFunctions.CheckForAccess(SecurityGroups.Add);

            var editWindow = new EditWindow();

            editWindow.ShowDialog();
        }