Skip to content

Commit

Permalink
Fix Bug that occur when client change selected season.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanDeveloper committed Jun 22, 2017
1 parent 83f3996 commit 88ce7fa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ public class BettorRankingWindowController
private BettorRankingWindowViewModel _viewModel;
private BettorClientServiceClient _bettorClient;
private MainWindow _mainWindow;
private MenuWindowController _menuWindow;
private Season _selectedSeason;
private Bettor _bettor;

public void Initialize(MainWindow mainWindow, Season selectedSeason, Bettor bettor)
public void Initialize(MainWindow mainWindow, MenuWindowController menuWindow, Season selectedSeason, Bettor bettor)
{
_view = new BettorRankingWindow();
_bettorClient = new BettorClientServiceClient();
_mainWindow = mainWindow;
_menuWindow = menuWindow;
_selectedSeason = selectedSeason;
_bettor = bettor;

Expand Down Expand Up @@ -56,8 +58,7 @@ public void Initialize(MainWindow mainWindow, Season selectedSeason, Bettor bett

private void ExecuteBackCommand(object obj)
{
var menuWindow = new MenuWindowController();
menuWindow.Initialize(_mainWindow,_bettor);
_menuWindow.Initialize(_mainWindow,_bettor);
}

private void UpdateMatchDay(object sender, string s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ public class MatchesWindowController
private MatchesWindowViewModel _viewModel;
private BettorClientServiceClient _bettorClient;
private MainWindow _mainWindow;
private MenuWindowController _menuWindow;
private Season _selectedSeason;
private Bettor _bettor;

public void Initialize(MainWindow mainWindow, Season selectedSeason, Bettor bettor)
public void Initialize(MainWindow mainWindow, MenuWindowController menuWindow, Season selectedSeason, Bettor bettor)
{
_view = new MatchesWindow();
_bettorClient = new BettorClientServiceClient();
_mainWindow = mainWindow;
_menuWindow = menuWindow;
_selectedSeason = selectedSeason;
_bettor = bettor;

Expand Down Expand Up @@ -52,8 +54,7 @@ public void Initialize(MainWindow mainWindow, Season selectedSeason, Bettor bett

private void ExecuteBackCommand(object obj)
{
var menuWindow = new MenuWindowController();
menuWindow.Initialize(_mainWindow, _bettor);
_menuWindow.Initialize(_mainWindow, _bettor);
}


Expand Down
20 changes: 10 additions & 10 deletions LigaManagerBettorClient/Controllers/MenuWindowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class MenuWindowController
private BettorClientServiceClient _bettorClient;
private MenuWindow _view;

private Season _selectedSeason;

public void Initialize(MainWindow mainWindow, Bettor bettor)
{
_view = new MenuWindow();
Expand All @@ -29,12 +31,12 @@ public void Initialize(MainWindow mainWindow, Bettor bettor)
{
Bettor = _bettor,
Seasons = new ObservableCollection<Season>(seasons.ToList()),
SelectedSeason = seasons.ToList().FirstOrDefault(),
SelectedSeason = _selectedSeason ?? seasons.FirstOrDefault(),
BettorRankingCommand = new RelayCommand(ExecuteBettorRankingCommand),
MatchesCommand = new RelayCommand(ExecuteMatchesCommand),
TeamsCommand = new RelayCommand(ExecuteTeamsCommand),
};

_selectedSeason = _selectedSeason != null ? _viewModel.SelectedSeason : seasons.FirstOrDefault();
_view.DataContext = _viewModel;
#endregion

Expand All @@ -47,26 +49,24 @@ public void Initialize(MainWindow mainWindow, Bettor bettor)
public void ExecuteBettorRankingCommand(object obj)
{
var bettorRanking = new BettorRankingWindowController();
bettorRanking.Initialize(_mainWindow, _viewModel.SelectedSeason, _bettor);
_selectedSeason = _viewModel.SelectedSeason;
bettorRanking.Initialize(_mainWindow, this, _viewModel.SelectedSeason, _bettor);
}

public void ExecuteMatchesCommand(object obj)
{
var matches = new MatchesWindowController();
matches.Initialize(_mainWindow, _viewModel.SelectedSeason, _bettor);
_selectedSeason = _viewModel.SelectedSeason;
matches.Initialize(_mainWindow, this, _viewModel.SelectedSeason, _bettor);
}

public void ExecuteTeamsCommand(object obj)
{
var teamRankingWindowController = new TeamRankingWindowController();
teamRankingWindowController.Initialize(_mainWindow, _viewModel.SelectedSeason, _bettor);
_selectedSeason = _viewModel.SelectedSeason;
teamRankingWindowController.Initialize(_mainWindow, this, _viewModel.SelectedSeason, _bettor);
}

public void ExecuteBackCommand(object obj)
{
_view.DataContext = _viewModel;
_mainWindow.Content = _view;
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ public class TeamRankingWindowController
private BettorClientServiceClient _bettorClient;

private MainWindow _mainWindow;
private MenuWindowController _menuWindow;
private Season _selectedSeason;
private Bettor _bettor;


public void Initialize(MainWindow mainWindow, Season selectedSeason, Bettor bettor)
public void Initialize(MainWindow mainWindow, MenuWindowController menuWindow, Season selectedSeason, Bettor bettor)
{
_view = new TeamRankingWindow();
_bettorClient = new BettorClientServiceClient();
_mainWindow = mainWindow;
_menuWindow = menuWindow;
_selectedSeason = selectedSeason;
_bettor = bettor;

Expand Down Expand Up @@ -54,8 +56,7 @@ public void Initialize(MainWindow mainWindow, Season selectedSeason, Bettor bett

private void ExecuteBackCommand(object obj)
{
var menuWindow = new MenuWindowController();
menuWindow.Initialize(_mainWindow, _bettor);
_menuWindow.Initialize(_mainWindow, _bettor);
}

private void UpdateMatchDay(object sender, string s)
Expand Down

0 comments on commit 88ce7fa

Please sign in to comment.