Пример #1
0
        public MainViewModel(IConnectivityService connectivityService, IDialogService dialogService)
        {
            _connectivityService    = connectivityService;
            _dialogService          = dialogService;
            ShowCompetitionsCommand = new MvxCommand <int>((id) =>
            {
                bool online = _connectivityService.CheckOnline();
                if (_connectivityService.CheckOnline())
                {
                    string sName = GetSportNameById(id);
                    ShowViewModel <ShowCompetitionsViewModel>(new { sportId = id, sportName = sName });
                }
                else
                {
                    _dialogService.ShowAlert("Please connect to internet and try again", "No Internet Connection", "OK");
                }
            });

            ShowMatchesCommand = new MvxCommand(() => {
                Competition c = new Competition()
                {
                    Name = "Premier League"
                };
                ShowViewModel <ShowMatchesViewModel>(new { compName = "Premier League" });
            });
        }
        public ShowMatchesViewModel(IMatchDataService matchDataService,
                                    IMvxMessenger messenger, IMvxWebBrowserTask webBrowser, IConnectivityService connectivityService,
                                    IDialogService dialogService)
        {
            _connectivityService = connectivityService;
            _dialogService       = dialogService;
            _webBrowser          = webBrowser;
            _comboCalcService    = new CombinationCalculator();
            matchOutcomes        = new Dictionary <Match, string>();
            _matchDataService    = matchDataService;
            _token    = messenger.Subscribe <OutcomeSelectedMessage>(UpdateVendorValue);
            Messenger = messenger;

            DirectToWebPageCommand = new MvxCommand(() => {
                if (_connectivityService.CheckOnline())
                {
                    try
                    {
                        _webBrowser.ShowWebPage(VendorValue.Vendor.Url);
                    }
                    catch (Exception)
                    {
                        _dialogService.ShowAlert("Ups, something went wrong when trying to redirct", "Couldn't redirct", "OK");
                    }
                }
                else
                {
                    _dialogService.ShowAlert("Please connect to internet and try again", "Couldn't redirct. No Internet Connection", "OK");
                }
            });
        }