示例#1
0
            public static void Add <TBasedProxy, TExtendedProxy, TWindow>(Func <TExtendedProxy, bool, TWindow> getWindow, IDatabaseEditor <TBasedProxy, TExtendedProxy> databaseEditor) where TWindow : Window, IProxyWindowWithExtendedProxy <TExtendedProxy>
            {
                var window = getWindow(default(TExtendedProxy), false);

                if (window.ShowDialog() != true)
                {
                    return;
                }

                SafeRunMethod.WithoutReturn(() => databaseEditor.Add(window.ExtendedProxy));
            }
示例#2
0
            public static void Delete <TTable>(TTable selectedItem, IDatabaseEditor <TTable> databaseEditor, Func <TTable, Guid> getId, Action actionAfterSuccess = null)
            {
                if (selectedItem == null)
                {
                    return;
                }

                SafeRunMethod.WithoutReturn(() => {
                    databaseEditor.Delete(getId(selectedItem));
                    actionAfterSuccess?.Invoke();
                });
            }
示例#3
0
            public static void Add <TTable, TWindow>(Func <TTable, bool, TWindow> getWindow, IDatabaseEditor <TTable> databaseEditor, Action actionAfterSuccess = null) where TWindow : Window, IWindowWithChecking <TTable>
            {
                var window = getWindow(default(TTable), false);

                if (window.ShowDialog() != true)
                {
                    return;
                }

                SafeRunMethod.WithoutReturn(() => {
                    databaseEditor.Add(window.Table);
                    actionAfterSuccess?.Invoke();
                });
            }
示例#4
0
            public static void View <TBasedProxy, TExtendedProxy>(TBasedProxy selectedItem, IDatabaseReader <TBasedProxy, TExtendedProxy> databaseReader, Func <TExtendedProxy, bool, Window> getWindow)
            {
                if (selectedItem == null)
                {
                    return;
                }

                var extendedProxy = SafeRunMethod.WithReturn(() => databaseReader.GetExtendedProxy(selectedItem));

                if (extendedProxy == null)
                {
                    return;
                }

                getWindow(extendedProxy, true).ShowDialog();
            }
示例#5
0
            public static void TrueDialogResult <TWindow>(TWindow window) where TWindow : Window, IWindowWithChecking
            {
                var errors = window.GetErrors().ToArray();

                if (errors.Any())
                {
                    ShowMessageBox.Error(string.Join("\n", errors));
                    return;
                }

                SafeRunMethod.WithoutReturn(() => {
                    window.ActionBeforeTrueDialogResultClose();
                    window.DialogResult = true;
                    window.Close();
                });
            }
示例#6
0
            public static void Edit <TTable, TWindow>(TTable selectedItem, Func <TTable, bool, TWindow> getWindow, IDatabaseEditor <TTable> databaseEditor, Func <TTable, Guid> getId, Action actionAfterSuccess = null) where TWindow : Window, IWindowWithChecking <TTable>
            {
                if (selectedItem == null)
                {
                    return;
                }

                var window = getWindow(selectedItem, false);

                if (window.ShowDialog() != true)
                {
                    return;
                }

                SafeRunMethod.WithoutReturn(() => {
                    databaseEditor.Edit(getId(selectedItem), window.Table);
                    actionAfterSuccess?.Invoke();
                });
            }
示例#7
0
            public static void Edit <TBasedProxy, TExtendedProxy, TWindow>(TBasedProxy selectedItem, IDatabaseReader <TBasedProxy, TExtendedProxy> databaseReader, Func <TExtendedProxy, bool, TWindow> getWindow, IDatabaseEditor <TBasedProxy, TExtendedProxy> databaseEditor) where TWindow : Window, IProxyWindowWithExtendedProxy <TExtendedProxy>
            {
                if (selectedItem == null)
                {
                    return;
                }

                var oldProxy = SafeRunMethod.WithReturn(() => databaseReader.GetExtendedProxy(selectedItem));

                if (oldProxy == null)
                {
                    return;
                }

                var window = getWindow(oldProxy, false);

                if (window.ShowDialog() != true)
                {
                    return;
                }

                SafeRunMethod.WithoutReturn(() => databaseEditor.Edit(oldProxy, window.ExtendedProxy));
            }
示例#8
0
 private static string[] GetGroupNames(HttpClientProvider httpClientProvider)
 {
     return(SafeRunMethod.WithReturn(() => httpClientProvider.GetDatabaseGroupReader().GetAllBasedProies())?.Select(group => group.GroupName).ToArray());
 }