implementet ErrorMessages
This commit is contained in:
@@ -21,8 +21,10 @@ namespace Apollon.EntityFramework.Commands
|
||||
|
||||
public async Task Execute(Tournament tournament)
|
||||
{
|
||||
throw new Exception();
|
||||
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
{
|
||||
{
|
||||
TournamentDto tournamentDto = new TournamentDto()
|
||||
{
|
||||
Id = tournament.Id,
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Apollon.EntityFramework.Commands
|
||||
}
|
||||
|
||||
public async Task Execute(Guid id)
|
||||
{
|
||||
{
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
{
|
||||
TournamentDto tournamentDto = new TournamentDto()
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Apollon.EntityFramework.Commands
|
||||
}
|
||||
|
||||
public async Task Execute(Tournament tournament)
|
||||
{
|
||||
{
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
{
|
||||
TournamentDto tournamentDto = new TournamentDto()
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Apollon.EntityFramework.Queries
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Tournament>> Execute()
|
||||
{
|
||||
{
|
||||
using (TournamentsDbContext context = _contextFactory.Create())
|
||||
{
|
||||
IEnumerable<TournamentDto> tournamentsDtos = await context.Tournaments.ToListAsync();
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
AddEditDetailsViewModel detailsViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
||||
|
||||
detailsViewModel.ErrorMessage = null;
|
||||
detailsViewModel.IsSubmitting = true;
|
||||
|
||||
Tournament tournament = new Tournament(
|
||||
@@ -51,7 +52,7 @@ namespace Apollon.WPF.Commands
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
detailsViewModel.ErrorMessage = "Daten konnten nicht gespeichert werden!";
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Apollon.WPF.Commands
|
||||
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
_warningDeleteViewModel.ErrorMessage = null;
|
||||
_warningDeleteViewModel.IsDeleting = true;
|
||||
|
||||
Tournament tournament = _overviewListingItemViewModel.Tournament;
|
||||
@@ -43,7 +44,7 @@ namespace Apollon.WPF.Commands
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
_warningDeleteViewModel.ErrorMessage = "Speichern fehlgeschlagen!";
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
AddEditDetailsViewModel detailsViewModel = _editTournamentViewModel.AddEditDetailsViewModel;
|
||||
|
||||
detailsViewModel.ErrorMessage = null;
|
||||
detailsViewModel.IsSubmitting = true;
|
||||
|
||||
Tournament tournament = new Tournament(
|
||||
@@ -48,7 +49,7 @@ namespace Apollon.WPF.Commands
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
detailsViewModel.ErrorMessage = "Daten konnten nicht gespeichert werden!";
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Apollon.WPF.Commands
|
||||
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
_overviewViewModel.ErrorMessage = null;
|
||||
_overviewViewModel.IsLoading = true;
|
||||
|
||||
try
|
||||
@@ -29,7 +30,7 @@ namespace Apollon.WPF.Commands
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
_overviewViewModel.ErrorMessage = "Daten konnten nicht geladen werden! Bitte starten Sie die Anwendung neu!";
|
||||
}
|
||||
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 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 LoadTournamentsCommand { get; }
|
||||
public ICommand NavigateNavBarCommand { get; }
|
||||
|
||||
@@ -24,7 +24,25 @@ namespace Apollon.WPF.ViewModels
|
||||
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 WarningDeleteViewModel(ModalNavigationStore modalNavigationStore,TournamentsStore tournamentsStore, OverviewListingItemViewModel overviewListingItemViewModel)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
xmlns:local="clr-namespace:Apollon.WPF.Views.Components"
|
||||
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="55"/>
|
||||
@@ -127,6 +130,14 @@
|
||||
HorizontalAlignment="Left"
|
||||
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.ColumnSpan="2"
|
||||
Margin="0 30 0 0"
|
||||
|
||||
@@ -100,10 +100,31 @@
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource BrushPrimary1}"
|
||||
Margin="0 0 0 30"
|
||||
FontSize="14">
|
||||
FontSize="14">
|
||||
</TextBlock>
|
||||
<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.Column="2"
|
||||
@@ -116,8 +137,12 @@
|
||||
<DataTrigger Binding="{Binding IsLoading}" Value="false">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding HasErrorMessage}" Value="true">
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</Grid.Style>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="20"
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<StackPanel Grid.ColumnSpan="2"
|
||||
MaxWidth="300">
|
||||
@@ -51,6 +54,15 @@
|
||||
Color="{StaticResource BrushPrimary1}"
|
||||
IsLoading="{Binding IsDeleting}"/>
|
||||
</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>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user