implementet ErrorMessages
This commit is contained in:
@@ -21,6 +21,8 @@ namespace Apollon.EntityFramework.Commands
|
|||||||
|
|
||||||
public async Task Execute(Tournament tournament)
|
public async Task Execute(Tournament tournament)
|
||||||
{
|
{
|
||||||
|
throw new Exception();
|
||||||
|
|
||||||
using (TournamentsDbContext context = _contextFactory.Create())
|
using (TournamentsDbContext context = _contextFactory.Create())
|
||||||
{
|
{
|
||||||
TournamentDto tournamentDto = new TournamentDto()
|
TournamentDto tournamentDto = new TournamentDto()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace Apollon.WPF.Commands
|
|||||||
{
|
{
|
||||||
AddEditDetailsViewModel detailsViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
AddEditDetailsViewModel detailsViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
||||||
|
|
||||||
|
detailsViewModel.ErrorMessage = null;
|
||||||
detailsViewModel.IsSubmitting = true;
|
detailsViewModel.IsSubmitting = true;
|
||||||
|
|
||||||
Tournament tournament = new Tournament(
|
Tournament tournament = new Tournament(
|
||||||
@@ -51,7 +52,7 @@ namespace Apollon.WPF.Commands
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
throw;
|
detailsViewModel.ErrorMessage = "Daten konnten nicht gespeichert werden!";
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace Apollon.WPF.Commands
|
|||||||
|
|
||||||
public override async Task ExecuteAsync(object parameter)
|
public override async Task ExecuteAsync(object parameter)
|
||||||
{
|
{
|
||||||
|
_warningDeleteViewModel.ErrorMessage = null;
|
||||||
_warningDeleteViewModel.IsDeleting = true;
|
_warningDeleteViewModel.IsDeleting = true;
|
||||||
|
|
||||||
Tournament tournament = _overviewListingItemViewModel.Tournament;
|
Tournament tournament = _overviewListingItemViewModel.Tournament;
|
||||||
@@ -43,7 +44,7 @@ namespace Apollon.WPF.Commands
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
throw;
|
_warningDeleteViewModel.ErrorMessage = "Speichern fehlgeschlagen!";
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace Apollon.WPF.Commands
|
|||||||
{
|
{
|
||||||
AddEditDetailsViewModel detailsViewModel = _editTournamentViewModel.AddEditDetailsViewModel;
|
AddEditDetailsViewModel detailsViewModel = _editTournamentViewModel.AddEditDetailsViewModel;
|
||||||
|
|
||||||
|
detailsViewModel.ErrorMessage = null;
|
||||||
detailsViewModel.IsSubmitting = true;
|
detailsViewModel.IsSubmitting = true;
|
||||||
|
|
||||||
Tournament tournament = new Tournament(
|
Tournament tournament = new Tournament(
|
||||||
@@ -48,7 +49,7 @@ namespace Apollon.WPF.Commands
|
|||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw;
|
detailsViewModel.ErrorMessage = "Daten konnten nicht gespeichert werden!";
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace Apollon.WPF.Commands
|
|||||||
|
|
||||||
public override async Task ExecuteAsync(object parameter)
|
public override async Task ExecuteAsync(object parameter)
|
||||||
{
|
{
|
||||||
|
_overviewViewModel.ErrorMessage = null;
|
||||||
_overviewViewModel.IsLoading = true;
|
_overviewViewModel.IsLoading = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -29,7 +30,7 @@ namespace Apollon.WPF.Commands
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
throw;
|
_overviewViewModel.ErrorMessage = "Daten konnten nicht geladen werden! Bitte starten Sie die Anwendung neu!";
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -139,7 +139,24 @@ namespace Apollon.WPF.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanSubmit => !string.IsNullOrEmpty(TournamentName);
|
private string _errorMessage;
|
||||||
|
public string ErrorMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _errorMessage;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_errorMessage = value;
|
||||||
|
OnPropertyChanged(nameof(ErrorMessage));
|
||||||
|
OnPropertyChanged(nameof(HasErrorMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasErrorMessage => !string.IsNullOrEmpty(ErrorMessage);
|
||||||
|
|
||||||
|
public bool CanSubmit => !string.IsNullOrEmpty(TournamentName);
|
||||||
|
|
||||||
public ICommand SubmitCommand { get; }
|
public ICommand SubmitCommand { get; }
|
||||||
public ICommand CancelCommand { get; }
|
public ICommand CancelCommand { get; }
|
||||||
|
|||||||
@@ -29,6 +29,23 @@ namespace Apollon.WPF.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string _errorMessage;
|
||||||
|
public string ErrorMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _errorMessage;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_errorMessage = value;
|
||||||
|
OnPropertyChanged(nameof(ErrorMessage));
|
||||||
|
OnPropertyChanged(nameof(HasErrorMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasErrorMessage => !string.IsNullOrEmpty(ErrorMessage);
|
||||||
|
|
||||||
public ICommand AddTournamentCommand { get; }
|
public ICommand AddTournamentCommand { get; }
|
||||||
public ICommand LoadTournamentsCommand { get; }
|
public ICommand LoadTournamentsCommand { get; }
|
||||||
public ICommand NavigateNavBarCommand { get; }
|
public ICommand NavigateNavBarCommand { get; }
|
||||||
|
|||||||
@@ -24,7 +24,25 @@ namespace Apollon.WPF.ViewModels
|
|||||||
OnPropertyChanged(nameof(IsDeleting));
|
OnPropertyChanged(nameof(IsDeleting));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ICommand WarningCloseCommand { get;}
|
|
||||||
|
private string _errorMessage;
|
||||||
|
public string ErrorMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _errorMessage;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_errorMessage = value;
|
||||||
|
OnPropertyChanged(nameof(ErrorMessage));
|
||||||
|
OnPropertyChanged(nameof(HasErrorMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasErrorMessage => !string.IsNullOrEmpty(ErrorMessage);
|
||||||
|
|
||||||
|
public ICommand WarningCloseCommand { get;}
|
||||||
public ICommand DeleteCommand { get; }
|
public ICommand DeleteCommand { get; }
|
||||||
public WarningDeleteViewModel(ModalNavigationStore modalNavigationStore,TournamentsStore tournamentsStore, OverviewListingItemViewModel overviewListingItemViewModel)
|
public WarningDeleteViewModel(ModalNavigationStore modalNavigationStore,TournamentsStore tournamentsStore, OverviewListingItemViewModel overviewListingItemViewModel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
xmlns:local="clr-namespace:Apollon.WPF.Views.Components"
|
xmlns:local="clr-namespace:Apollon.WPF.Views.Components"
|
||||||
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
|
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="55"/>
|
<RowDefinition Height="55"/>
|
||||||
@@ -127,6 +130,14 @@
|
|||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Background="LightGray"/>
|
Background="LightGray"/>
|
||||||
|
|
||||||
|
<TextBlock Text="{Binding ErrorMessage}"
|
||||||
|
Grid.Row="7"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
TextAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
Foreground="Red"
|
||||||
|
Visibility="{Binding HasErrorMessage, Converter= {StaticResource BooleanToVisibilityConverter}}"/>
|
||||||
|
|
||||||
<Grid Grid.Row="7"
|
<Grid Grid.Row="7"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Margin="0 30 0 0"
|
Margin="0 30 0 0"
|
||||||
|
|||||||
@@ -104,6 +104,27 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
<custom:LoadingSpinner Diameter="50" IsLoading="True" Thickness="3" Color="{StaticResource BrushPrimary1}"/>
|
<custom:LoadingSpinner Diameter="50" IsLoading="True" Thickness="3" Color="{StaticResource BrushPrimary1}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Grid Width="250">
|
||||||
|
<Grid.Style>
|
||||||
|
<Style TargetType="Grid">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding HasErrorMessage}" Value="true">
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Grid.Style>
|
||||||
|
<TextBlock Text="{Binding ErrorMessage}"
|
||||||
|
FontSize="14"
|
||||||
|
Foreground="Red"
|
||||||
|
TextWrapping="WrapWithOverflow"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
TextAlignment="Center">
|
||||||
|
|
||||||
|
</TextBlock>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Column="2"
|
<Grid Grid.Column="2"
|
||||||
@@ -116,8 +137,12 @@
|
|||||||
<DataTrigger Binding="{Binding IsLoading}" Value="false">
|
<DataTrigger Binding="{Binding IsLoading}" Value="false">
|
||||||
<Setter Property="Visibility" Value="Visible"/>
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding HasErrorMessage}" Value="true">
|
||||||
|
<Setter Property="Visibility" Value="Hidden"/>
|
||||||
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
</Grid.Style>
|
</Grid.Style>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Margin="20"
|
<TextBlock Margin="20"
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
|
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel Grid.ColumnSpan="2"
|
<StackPanel Grid.ColumnSpan="2"
|
||||||
MaxWidth="300">
|
MaxWidth="300">
|
||||||
@@ -51,6 +54,15 @@
|
|||||||
Color="{StaticResource BrushPrimary1}"
|
Color="{StaticResource BrushPrimary1}"
|
||||||
IsLoading="{Binding IsDeleting}"/>
|
IsLoading="{Binding IsDeleting}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<TextBlock
|
||||||
|
Text="{Binding ErrorMessage}"
|
||||||
|
Margin="5"
|
||||||
|
Grid.Row="7"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
TextAlignment="Center"
|
||||||
|
FontSize="14"
|
||||||
|
Foreground="Red"
|
||||||
|
Visibility="{Binding HasErrorMessage, Converter= {StaticResource BooleanToVisibilityConverter}}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user