public MainWindowViewMode() { _Model = new MainWindowModel(); ViewSettingCommand = new MyDelegateCommand(ViewSettingCommandExe); CheckUpDataCommand = new MyDelegateCommand(CheckUpDataCommandExe); AbloutHelpCommand = new MyDelegateCommand(AbloutHelpCommandExe); }
public SettingWindowViewModel() { CheckMysqlDBConnectCommand = new MyDelegateCommand(CheckMysqlDBConnectCommandExe); SaveSettingCommand = new MyDelegateCommand(SaveSettingCommandExe); }
public EditMatchFormViewModel(IRegionManager regionManager, IRefereeService refereeService, IInteractionService interactionService, IGeocodingService geocodingService) { CalculateRouteCommand = new MyDelegateCommand(CalculateRoute); this.regionManager = regionManager; this.refereeService = refereeService; this.interactionService = interactionService; this.geocodingService = geocodingService; AddGoalCommand = new DelegateCommand(() => { var teamId = Match.HomeTeamPlayers.Contains(SelectedPlayer) ? (SelectedType == GoalType.Own ? Match.AwayTeamId : Match.HomeTeamId) : (SelectedType == GoalType.Own ? Match.HomeTeamId : Match.AwayTeamId); var goal = new GoalDTO() { Scorer = SelectedPlayer, GoalType = SelectedType, TeamId = teamId, Time = Time }; if (teamId == Match.HomeTeamId) { HomeGoals.Add(goal); var ordered = this.HomeGoals.OrderBy(x => x.Time).ToList(); this.HomeGoals.Clear(); this.HomeGoals.AddRange(ordered); Match.HomeTeamScore = (Match.HomeTeamScore ?? 0) + 1; } else { AwayGoals.Add(goal); var ordered = this.AwayGoals.OrderBy(x => x.Time).ToList(); this.AwayGoals.Clear(); this.AwayGoals.AddRange(ordered); Match.AwayTeamScore = (Match.AwayTeamScore ?? 0) + 1; } this.interactionService.ShowMessageBox("Success", "Goal was added successfully"); }); RemoveGoalCommand = new DelegateCommand <GoalDTO>((goal) => { if (HomeGoals.Contains(goal)) { HomeGoals.Remove(goal); Match.HomeTeamScore--; } else { AwayGoals.Remove(goal); Match.AwayTeamScore--; } }); OkCommand = new DelegateCommand(async() => { if (IsEditing) { IsEnabled = true; Match.HomeTeamGoals = HomeGoals.ToArray(); Match.AwayTeamGoals = AwayGoals.ToArray(); if (Match.HomeTeamScore == null) { Match.HomeTeamScore = 0; } if (Match.AwayTeamScore == null) { Match.AwayTeamScore = 0; } await this.refereeService.SaveGoalsAsync(Match); IsEnabled = false; } GlobalCommands.GoBackCommand.Execute(null); }); }