-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d77909
commit ff4f156
Showing
30 changed files
with
468 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
LigaManagerAdminClient/Controllers/AddSeasonWindowController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using LigaManagerAdminClient.AdminClientService; | ||
using LigaManagerAdminClient.ViewModels; | ||
using LigaManagerAdminClient.Views; | ||
using LigaManagerBettorClient.Frameworks; | ||
using LigaManagerServer.Models; | ||
|
||
namespace LigaManagerAdminClient.Controllers | ||
{ | ||
public class AddSeasonWindowController | ||
{ | ||
private AddSeasonWindow _view; | ||
private AddSeasonWindowViewModel _viewModel; | ||
|
||
public Season Season { get; set; } | ||
|
||
public Season ShowSeason() | ||
{ | ||
#region View And ViewModel | ||
_view = new AddSeasonWindow(); | ||
_viewModel = new AddSeasonWindowViewModel | ||
{ | ||
Season = Season, | ||
OkCommand = new RelayCommand(ExecuteOkCommand), | ||
CancelCommand = new RelayCommand(ExecuteCancelCommand), | ||
}; | ||
_view.DataContext = _viewModel; | ||
#endregion | ||
|
||
return _view.ShowDialog() == true ? _viewModel.Season : null; | ||
} | ||
|
||
public void ExecuteOkCommand(object obj) | ||
{ | ||
_view.DialogResult = true; | ||
_view.Close(); | ||
} | ||
|
||
public void ExecuteCancelCommand(object obj) | ||
{ | ||
_view.DialogResult = false; | ||
_view.Close(); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
LigaManagerAdminClient/Controllers/AddTeamWindowController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Collections.Generic; | ||
using LigaManagerAdminClient.ViewModels; | ||
using LigaManagerAdminClient.Views; | ||
using LigaManagerBettorClient.Frameworks; | ||
using LigaManagerServer.Models; | ||
|
||
namespace LigaManagerAdminClient.Controllers | ||
{ | ||
public class AddTeamWindowController | ||
{ | ||
private AddTeamWindow _view; | ||
private AddTeamWindowViewModel _viewModel; | ||
|
||
public Team Team { get; set; } | ||
public List<Season> Seasons { get; set; } | ||
|
||
public Team ShowTeam() | ||
{ | ||
#region View and ViewModel | ||
_view = new AddTeamWindow(); | ||
_viewModel = new AddTeamWindowViewModel() | ||
{ | ||
OkCommand = new RelayCommand(ExecuteOkCommand), | ||
CancelCommand = new RelayCommand(ExecuteCancelCommand), | ||
}; | ||
_view.DataContext = _viewModel; | ||
#endregion | ||
|
||
return _view.ShowDialog() == true ? _viewModel.Team : null; | ||
} | ||
|
||
public void ExecuteOkCommand(object obj) | ||
{ | ||
_view.DialogResult = true; | ||
_view.Close(); | ||
} | ||
|
||
public void ExecuteCancelCommand(object obj) | ||
{ | ||
_view.DialogResult = false; | ||
_view.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 132 additions & 3 deletions
135
LigaManagerAdminClient/Controllers/SeasonWindowController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,141 @@ | ||
using LigaManagerAdminClient.Views; | ||
using System.Linq; | ||
using System.Windows; | ||
using LigaManagerAdminClient.AdminClientService; | ||
using LigaManagerAdminClient.Framework; | ||
using LigaManagerAdminClient.ViewModels; | ||
using LigaManagerAdminClient.Views; | ||
using LigaManagerBettorClient.Frameworks; | ||
using LigaManagerServer.Models; | ||
|
||
namespace LigaManagerAdminClient.Controllers | ||
{ | ||
public class SeasonWindowController | ||
{ | ||
public void Initialize(MainWindow mainWindow) | ||
private SeasonWindow _view; | ||
private SeasonWindowViewModel _viewModel; | ||
private AdminClientServiceClient _adminClient; | ||
private MainWindow _mainWindow; | ||
|
||
|
||
public async void Initialize(MainWindow mainWindow) | ||
{ | ||
_mainWindow = mainWindow; | ||
_adminClient = new AdminClientServiceClient(); | ||
|
||
#region View And ViewModel | ||
_view = new SeasonWindow(); | ||
var seasons = await _adminClient.GetSeasonsAsync(); | ||
_viewModel = new SeasonWindowViewModel | ||
{ | ||
BackCommand = new RelayCommand(ExecuteBackCommand), | ||
AddCommand = new RelayCommand(ExecuteAddCommand), | ||
DeleteCommand = new RelayCommand(ExecuteDeleteCommand), | ||
ChangeCommand = new RelayCommand(ExecuteChangeCommand), | ||
Seasons = seasons.ToList(), | ||
SelectedSeason = seasons.ToList().FirstOrDefault() | ||
}; | ||
_view.DataContext = _viewModel; | ||
#endregion | ||
|
||
_mainWindow.Content = _view; | ||
} | ||
|
||
#region ExecuteCommands | ||
private void ExecuteBackCommand(object obj) | ||
{ | ||
var menuWindow = new MenuWindowController(); | ||
menuWindow.Initialize(_mainWindow); | ||
} | ||
|
||
private async void ExecuteAddCommand(object obj) | ||
{ | ||
var addSeasonWindow = new AddSeasonWindowController | ||
{ | ||
Season = new Season() | ||
}; | ||
var showSeason = addSeasonWindow.ShowSeason(); | ||
// it could be possible that the bettor is null | ||
if (showSeason == null) return; | ||
// Check if service is available | ||
if (!await AdminClientHelper.IsAvailable(_adminClient)) return; | ||
// add bettor | ||
var addBettorAsync = await _adminClient.AddSeasonAsync(showSeason); | ||
|
||
if (addBettorAsync) | ||
{ | ||
ReloadSeason(); | ||
} | ||
else | ||
{ | ||
MessageBox.Show("Saison konnte nicht hinzugefügt werden, da der Name schon vergeben ist!", "Hinzufügen fehlgeschlagen", | ||
MessageBoxButton.OK, MessageBoxImage.Error); | ||
} | ||
} | ||
|
||
private async void ReloadSeason() | ||
{ | ||
var seasons = await _adminClient.GetSeasonsAsync(); | ||
_viewModel.Seasons = seasons.ToList(); | ||
} | ||
|
||
private async void ExecuteChangeCommand(object obj) | ||
{ | ||
if (_viewModel.SelectedSeason == null) | ||
{ | ||
MessageBox.Show("Bitte wählen Sie eine Saison aus!", "Keine Saison ausgewählt", | ||
MessageBoxButton.OK, MessageBoxImage.Warning); | ||
return; | ||
} | ||
var addSeasonWindow = new AddSeasonWindowController | ||
{ | ||
Season = _viewModel.SelectedSeason | ||
}; | ||
|
||
var showSeason = addSeasonWindow.ShowSeason(); | ||
// it could be possible that the bettor is null | ||
if (showSeason == null) return; | ||
// Check if service is available | ||
if (!await AdminClientHelper.IsAvailable(_adminClient)) return; | ||
// add bettor | ||
var isUpdated = await _adminClient.UpdateSeasonAsync(showSeason); | ||
|
||
if (isUpdated) | ||
{ | ||
ReloadSeason(); | ||
} | ||
else | ||
{ | ||
MessageBox.Show("Die Saison konnte nicht geändert werden!", "Änderung fehlgeschlagen", | ||
MessageBoxButton.OK, MessageBoxImage.Error); | ||
} | ||
} | ||
|
||
private async void ExecuteDeleteCommand(object obj) | ||
{ | ||
throw new System.NotImplementedException(); | ||
if (_viewModel.SelectedSeason == null) | ||
{ | ||
MessageBox.Show("Bitte wählen Sie eine Saison aus!", "Keine Saison ausgewählt", | ||
MessageBoxButton.OK, MessageBoxImage.Warning); | ||
return; | ||
} | ||
// Check if the user really want to delete the bettor | ||
var messageBoxResult = MessageBox.Show("Sind Sie sicher, dass die Saison gelöscht werden soll!", "Benutzer löschen", | ||
MessageBoxButton.YesNo, MessageBoxImage.Warning); | ||
if (messageBoxResult != MessageBoxResult.Yes) return; | ||
// Check if service is available | ||
if (!await AdminClientHelper.IsAvailable(_adminClient)) return; | ||
// delete bettor | ||
var isDeleted = await _adminClient.DeleteSeasonAsync(_viewModel.SelectedSeason); | ||
if (isDeleted) | ||
{ | ||
ReloadSeason(); | ||
} | ||
else | ||
{ | ||
MessageBox.Show("Saison konnte nicht gelöscht werden!", "Löschen fehlgeschlagen", | ||
MessageBoxButton.OK, MessageBoxImage.Error); | ||
} | ||
} | ||
#endregion | ||
} | ||
} |
Oops, something went wrong.