public FixturesFormViewModel(IRegionManager regionManager, IInteractionService interactionService, ILeagueService leagueService) { this.regionManager = regionManager; this.leagueService = leagueService; this.interactionService = interactionService; this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); var result = await this.leagueService.GenerateFixtures(this.SelectedItem.Id, this.StartingDate, this.IntervalValue); if (!result) { this.IsEnabled = GlobalCommands.UnlockWindowButtons(); await this.interactionService.ShowConfirmationMessage("Fixture already exists", "Fixture can't be generated, because it already exists. Do you want to override?", async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.GenerateFixtures(this.SelectedItem.Id, this.StartingDate, this.IntervalValue, true); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); } }); }
public TeamToSeasonFormViewModel(IRegionManager regionManager, IInteractionService interactionService, ILeagueService leagueService) { this.regionManager = regionManager; this.interactionService = interactionService; this.leagueService = leagueService; this.OKCommand = new DelegateCommand(async() => { if (this.SelectedItem != null) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); var result = this.leagueService.AssignTeamToSeason(SelectedItem.Id, this.seasonId); if (!(await result)) { await this.interactionService.ShowMessageBox("Team already added", "This team was already assigned to this season."); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); return; } } else { await this.interactionService.ShowMessageBox("No seasons available", "To assign team to season, add season first."); } GlobalCommands.GoBackCommand.Execute(null); }); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?refereeId = (int?)navigationContext.Parameters["id"]; if (!refereeId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddReferee(this.Referee); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.SaveChangesAsync(); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); this.Referee = await this.leagueService.GetReferee(refereeId.Value); if (this.Referee.Matches != null) { this.Matches.AddRange(this.Referee.Matches); } } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?stadiumId = (int?)navigationContext.Parameters["id"]; if (!stadiumId.HasValue) { this.OKCommand = new DelegateCommand(async() => { await this.leagueService.AddStadium(this.Stadium); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { await this.leagueService.SaveChangesAsync(); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); this.Stadium = await this.leagueService.GetStadium(stadiumId.Value); this.Header = "Edit existing stadium"; } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?coachId = (int?)navigationContext.Parameters["id"]; if (!coachId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddCoach(this.Coach); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.SaveChangesAsync(); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); this.Coach = await this.leagueService.GetCoach(coachId.Value); this.TeamLabel = (this.Coach.Teams != null && this.Coach.Teams.Any()) ? string.Join(", ", Array.ConvertAll(this.Coach.Teams.ToArray(), x => x.Name)) : "No team"; this.Header = "Edit existing coach"; } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Match = await this.leagueService.GetMatch((int)navigationContext.Parameters["id"]); this.AwayGoals.AddRange(Match.Goals.Where(g => g.TeamID == this.Match.AwayTeamId)); this.HomeGoals.AddRange(Match.Goals.Where(g => g.TeamID == this.Match.HomeTeamId)); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.seasonId = (int)navigationContext.Parameters["id"]; this.Teams.AddRange(await this.leagueService.GetTeamsList()); //if(this.Teams.Any()) //{ // this.SelectedItem = this.Teams.First(); //} this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Teams.AddRange(await this.leagueService.GetTeamsList()); int?playerId = (int?)navigationContext.Parameters["id"]; if (!playerId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Footballer.TeamId = SelectedTeam?.Id; var result = await this.leagueService.AddFootballer(this.Footballer); if (!result) { await this.interactionService.ShowMessageBox("Cannot add player", "Salary is too high."); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); } else { regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); } }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); if (await this.leagueService.CanAddFootballer(this.Footballer)) { this.Footballer.TeamId = SelectedTeam?.Id; await this.leagueService.SaveChangesAsync(); GlobalCommands.GoBackCommand.Execute(null); } else { await this.interactionService.ShowMessageBox("Cannot edit player", "Salary is too high."); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); } }); this.Footballer = await this.leagueService.GetFootballer(playerId.Value); this.SelectedTeam = Teams.FirstOrDefault(t => t.Id == this.Footballer.TeamId); if (this.Footballer.Goals != null) { this.Goals.AddRange(this.Footballer.Goals); } } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
/// <summary> /// Event for text changes in searchtextbox. /// </summary> private void SearchTextbox_OnTextChanged(object sender, TextChangedEventArgs e) { var origin = sender as TextBox; if (!origin.IsFocused) { return; } DisposeTimer(); this.okButton.IsEnabled = false; this.cancelButton.IsEnabled = false; GlobalCommands.BlockWindowButtons(); timer = new Timer(TimerElapsed, null, VALIDATION_DELAY, VALIDATION_DELAY); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); int?seasonId = (int?)navigationContext.Parameters["id"]; if (!seasonId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddSeason(this.Season); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { await this.leagueService.SaveChangesAsync(); //regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); GlobalCommands.GoBackCommand.Execute(null); }); this.AddTeamCommand = new DelegateCommand(() => { var parameter = new NavigationParameters(); parameter.Add("id", this.Season.Id); this.regionManager.RequestNavigate(UiRegions.MainRegion, nameof(TeamToSeasonForm), parameter); }); this.Season = await this.leagueService.GetSeason(seasonId.Value); if (this.Season.Matches != null) { this.Season.Matches = this.Season.Matches.OrderBy(x => x.Date).ToList(); } OnPropertyChanged("Season"); if (this.Season.Table != null) { this.Table.AddRange(this.Season.Table.OrderByDescending(x => x.Points)); } this.AddTeamEnabled = true; } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Coaches.AddRange(await this.leagueService.GetCoachList()); this.Stadiums.AddRange(await this.leagueService.GetStadiumsList()); int?teamId = (int?)navigationContext.Parameters["id"]; if (!teamId.HasValue) { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); await this.leagueService.AddTeam(this.Team); regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); }); } else { this.OKCommand = new DelegateCommand(async() => { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Team.CoachId = this.SelectedCoach.Id; this.Team.StadiumId = this.SelectedStadium.Id; await this.leagueService.SaveChangesAsync(); //regionManager.RequestNavigate(UiRegions.MainRegion, nameof(MainMenu)); GlobalCommands.GoBackCommand.Execute(null); }); this.Team = await this.leagueService.GetTeam(teamId.Value); this.SelectedCoach = Coaches.FirstOrDefault(c => c.Id == Team.CoachId); this.SelectedStadium = Stadiums.FirstOrDefault(s => s.Id == Team.StadiumId); if (this.Team.Footballers != null) { this.Footballers.AddRange(Team.Footballers); } if (this.Team.Table != null) { this.Tables.AddRange(Team.Table); } } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }
public TeamFormViewModel(IRegionManager regionManager, IViewToDataService viewToDataService, ILeagueService leagueService, IInteractionService interactionService) { this.regionManager = regionManager; this.leagueService = leagueService; this.viewToDataService = viewToDataService; this.interactionService = interactionService; this.Team = new Team() { Address = new Address() }; this.RemovePlayerCommand = new DelegateCommand <Footballer>((Footballer player) => { if (player != null) { this.leagueService.RemovePlayerFromTeam(player); this.Footballers.Remove(player); OnPropertyChanged("Team"); } }); this.RemoveSeasonCommand = new DelegateCommand <Table>(async(Table table) => { if (table != null) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); var result = await this.leagueService.RemoveTeamFromSeason(table.Id); if (result) { this.Tables.Remove(table); } else { await this.interactionService.ShowMessageBox("Cannot remove team from season", "This team is already included in fixtures"); } this.IsEnabled = GlobalCommands.UnlockWindowButtons(); } }); }
public async void OnNavigatedTo(NavigationContext navigationContext) { this.IsEnabled = GlobalCommands.BlockWindowButtons(); this.Seasons.AddRange(await this.leagueService.GetSeasonsList()); this.IsEnabled = GlobalCommands.UnlockWindowButtons(); }