Example #1
0
        void fill()
        {
            this.config = FVOConfig.LoadFromKeyChain(App.KeyChain);
            Athlete admin = App.Repository.GetMyAthlete();

            if (string.IsNullOrEmpty(config.VenueName) == false)
            {
                this.labelVenue.Text = config.VenueName;
            }
            else
            {
                this.labelVenue.Text = "Pick venue";
            }

            this.pickerTableType.SelectedIndex = config.TableSize == SnookerTableSizeEnum.Table10Ft ? 0 : 1;
            this.entryTableDescription.Text    = config.TableDescription ?? "";

            int index = notableBreakThresholds.IndexOf(config.NotableBreakThreshold);

            if (index < 0)
            {
                index = 0;
            }
            this.pickerNotableBreakThreshold.SelectedIndex = index;

            this.labelAdmin.Text = admin.Name ?? "no name";
        }
Example #2
0
        public async Task Fill()
        {
            this.labelTop.Text = "loading...";

            int venueID = FVOConfig.LoadFromKeyChain(App.KeyChain).VenueID;

            var resultsWeb = await App.WebService.GetResultsAtVenue(venueID);

            var results = resultsWeb.Select(r => r.ToResult()).ToList();
            var scores  = await App.WebService.GetScoresAtVenue(venueID);

            bool failedToLoadFromWeb = results == null || scores == null;

            if (failedToLoadFromWeb)
            {
                scores  = App.Repository.GetScores(true);
                results = App.Repository.GetResults(true).ToList();
            }

            var matches = (from score in scores
                           select SnookerMatchScore.FromScore(score.AthleteAID, score)).ToList();
            var breaks = (from result in results
                          select SnookerBreak.FromResult(result)).ToList();

            await new CacheHelper().LoadFromWebserviceIfNecessary_People(App.Cache, results, scores);
            new CacheHelper().LoadNamesFromCache(App.Cache, breaks);
            new CacheHelper().LoadNamesFromCache(App.Cache, matches);

            listOfMatchesControl.Fill(matches);
            listOfBreaksControl.Fill(breaks);

            this.labelTop.Text = failedToLoadFromWeb ? "Failed to load. Internet issues?" : "History";
        }
Example #3
0
        bool alertAboutSettingsIfNecessary()
        {
            FVOConfig config = FVOConfig.LoadFromKeyChain(App.KeyChain);

            if (config.IsOk == false)
            {
                this.DisplayAlert("Byb", "First, tap on 'Settings' in the bottom-left corner of the screen, to set things up.", "OK");
                return(true);
            }
            return(false);
        }
Example #4
0
        private void buttonStartMatch_Clicked(object sender, EventArgs e)
        {
            if (alertAboutSettingsIfNecessary())
            {
                return;
            }

            this.registerControl.Clear();

            FVOConfig config = FVOConfig.LoadFromKeyChain(App.KeyChain);

            if (config.IsOk == false)
            {
                return;
            }

            if (personA == null || personB == null)
            {
                this.DisplayAlert("Byb", "Select both players before starting the match.", "OK");
                return;
            }

            SnookerMatchMetadata metadata = new SnookerMatchMetadata();

            metadata.Date = DateTime.Now;
            if (this.personA != null)
            {
                metadata.PrimaryAthleteID      = this.personA.ID;
                metadata.PrimaryAthleteName    = this.personA.Name;
                metadata.PrimaryAthletePicture = this.personA.Picture;
            }
            if (this.personB != null)
            {
                metadata.OpponentAthleteID   = this.personB.ID;
                metadata.OpponentAthleteName = this.personB.Name;
                metadata.OpponentPicture     = this.personB.Picture;
            }
            metadata.TableSize = config.TableSize;
            metadata.VenueID   = config.VenueID;
            metadata.VenueName = config.VenueName;

            RecordMatchPage page = new RecordMatchPage(metadata);

            this.Navigation.PushModalAsync(page);
            page.Disappearing += (s1, e1) =>
            {
                this.buttonReset_Clicked(this, EventArgs.Empty);
                this.PickingAthleteStatus = PickingAthleteStatusEnum.Existing;
            };
        }
        async void register(string pin, string name, string email)
        {
            PleaseWaitPage pleaseWaitPage = new PleaseWaitPage();

            await this.Navigation.PushModalAsync(pleaseWaitPage);

            string password = pin;

            if (password == null)
            {
                password = "";
            }

            // register
            var config    = FVOConfig.LoadFromKeyChain(App.KeyChain);
            int?athleteID = await App.WebService.RegisterFVO(email, password, name, config.VenueID);

            if (athleteID == null)
            {
                await this.Navigation.PopModalAsync();

                await App.Navigator.DisplayAlertErrorAsync("Could not register. Internet issues? Already registered?");

                return;
            }

            this.Clear();

            // load the athlete record
            var athlete = await App.WebService.GetPersonByID(athleteID.Value);

            if (athlete == null)
            {
                await this.Navigation.PopModalAsync();

                await App.Navigator.DisplayAlertErrorAsync("Unspecified error. Internet issues?");

                return;
            }

            await this.Navigation.PopModalAsync();

            if (this.UserRegistered != null)
            {
                this.UserRegistered(athlete);
            }
        }
Example #6
0
        public static FVOConfig LoadFromKeyChain(IKeyChain keychain)
        {
            FVOConfig config = null;

            try
            {
                string str = keychain.Get("FVOConfig");
                config = Newtonsoft.Json.JsonConvert.DeserializeObject <FVOConfig>(str);
            }
            catch (Exception)
            {
            }

            if (config == null)
            {
                config = new FVOConfig();
            }

            return(config);
        }