Пример #1
0
        /// <summary>
        /// Creates a new dto and sends it to the server to add it to the database
        /// Returns void because RelayCommand expects void as return value
        /// </summary>
        private async void OnNewCommand()
        {
            try
            {
                IsLoading = true;
                var dialogResult = _dialogService.ShowDtoEditorWindow(new T());

                if (dialogResult != null && dialogResult.Accepted && dialogResult.Value != null)
                {
                    var newdto  = dialogResult.Value;
                    var success = await _lookupApiService.AddNew(newdto);

                    if (success)
                    {
                        await ReloadList();
                    }
                }
            }
            catch (Exception e)
            {
                _loggingService.LogError($"Error during Insertion of new {typeof(T).ToString()}.", e);
                _dialogService.ShowError(e.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }