public TeleportHomeViewModel(IDispatcherService dispatcherService, string functionTag, IDialogService dialogService,
                                     ScoreInfoService scoreInfoService, HomePositionService homePositionService, TeleRecordService teleRecordService)
            : base(dispatcherService, functionTag)
        {
            _dialogService       = dialogService;
            _scoreInfoService    = scoreInfoService;
            _homePositionService = homePositionService;
            _teleRecordService   = teleRecordService;

            DataGridItemChanged = new RelayCommand <DataGridItemChangedEventArgs>(OnDataGridItemChanged);

            RefreshList = new RelayCommand(PrivateRefreshList);

            RemoveItem = new RelayCommand(() =>
            {
                if (_dialogService.ShowOKCancel("确定删除选中数据吗?"))
                {
                    _ = _homePositionService.RemoveAsync(SelectedItem);
                    HomePositions.Remove(SelectedItem);
                }
            }, () => { return(SelectedItem != null); });

            RemoveAll = new RelayCommand(() =>
            {
                if (_dialogService.ShowOKCancel("确定删除所有数据吗?"))
                {
                    _             = _homePositionService.RemoveAllAsync();
                    HomePositions = null;
                }
            }, () => { return(HomePositions != null); });

            AddAvailableVariables();

            PrivateRefreshList();
        }
        public TeleportCityViewModel(IDispatcherService dispatcherService, string functionTag, IDialogService dialogService,
                                     ScoreInfoService scoreInfoService, CityPositionService cityPositionService, TeleRecordService teleRecordService)
            : base(dispatcherService, functionTag)
        {
            _dialogService       = dialogService;
            _scoreInfoService    = scoreInfoService;
            _cityPositionService = cityPositionService;
            _teleRecordService   = teleRecordService;

            DataGridItemChanged = new RelayCommand <DataGridItemChangedEventArgs>(OnDataGridItemChanged);

            RefreshList = new RelayCommand(PrivateRefreshList);

            RemoveItem = new RelayCommand(() =>
            {
                if (_dialogService.ShowOKCancel("确定删除选中数据吗?"))
                {
                    _ = _cityPositionService.RemoveAsync(SelectedItem);
                    CityPositions.Remove(SelectedItem);
                }
            }, () => { return(SelectedItem != null); });

            RemoveAll = new RelayCommand(() =>
            {
                if (_dialogService.ShowOKCancel("确定删除所有数据吗?"))
                {
                    _             = _cityPositionService.RemoveAllAsync();
                    CityPositions = null;
                }
            }, () => { return(CityPositions != null); });

            AddData = new RelayCommand(() =>
            {
                if (string.IsNullOrEmpty(TeleCmd))
                {
                    _dialogService.ShowInformation("传送命令不能为空");
                    return;
                }
                if (CityPositions.FirstOrDefault(p => p.TeleCmd == TeleCmd) != null)
                {
                    _dialogService.ShowInformation("传送命令重复");
                    return;
                }

                var cityPosition = new CityPositionDto()
                {
                    CityName      = CityName,
                    TeleCmd       = TeleCmd,
                    TeleNeedScore = TeleNeedScore,
                    Pos           = Pos
                };
                _ = _cityPositionService.AddAsync(cityPosition);
                CityPositions.Add(cityPosition);
            });

            AddAvailableVariables();

            PrivateRefreshList();
        }