Esempio n. 1
0
 private void buttonReset_Clicked(object sender, EventArgs e)
 {
     this.personA            = null;
     this.personB            = null;
     this.activePlayerStatus = ActivePlayerStatusEnum.PlayerA;
     this.fillPickingAthletesPanel();
 }
Esempio n. 2
0
        void takePerson(PersonBasicWebModel person)
        {
            if (this.activePlayerStatus == ActivePlayerStatusEnum.PlayerA)
            {
                this.personA = person;
            }
            else
            {
                this.personB = person;
            }

            if (personA == null)
            {
                this.activePlayerStatus = ActivePlayerStatusEnum.PlayerA;
            }
            else if (personB == null)
            {
                this.activePlayerStatus = ActivePlayerStatusEnum.PlayerB;
            }
            else
            {
                this.activePlayerStatus = ActivePlayerStatusEnum.None;
            }

            this.fillPickingAthletesPanel();
        }
Esempio n. 3
0
        public ActionResult MiniSnookerProfile(int athleteID, string extraText = "", string nameIfNotFound = "Not found")
        {
            var person = new PeopleLogic(db).GetBasic(0, athleteID);

            string picture = person != null ? person.Picture : null;

            if (string.IsNullOrEmpty(picture) == false)
            {
                picture = ImageUrlHelper.MakeUrlForWebProfile(picture);
            }
            else
            {
                picture = new Uri("/images/default-snookerplayer.png", UriKind.Relative).ToString();
            }

            ViewBag.Picture = picture;

            ViewBag.ExtraText = extraText;

            if (person == null)
            {
                person      = new PersonBasicWebModel();
                person.Name = Url.Encode(nameIfNotFound);
                return(PartialView("MiniSnookerProfile", person));
            }

            return(PartialView("MiniSnookerProfile", person));
        }
Esempio n. 4
0
        public void Put(PersonBasicWebModel person)
        {
            var item = items.Where(i => i.Person.ID == person.ID).FirstOrDefault();

            if (item != null)
            {
                items.Remove(item);
            }
            items.Add(new CacheItem()
            {
                Person = person, TimeLoaded = DateTimeHelper.GetUtcNow()
            });
        }
Esempio n. 5
0
        void doOnOpponentSelected(PersonBasicWebModel person)
        {
            this.MatchScore.OpponentAthleteID = person.ID;
            this.MatchScore.OpponentName      = person.Name;
            this.MatchScore.OpponentPicture   = person.Picture;
            if (this.MatchScore.OpponentBreaks != null)
            {
                foreach (var b in this.MatchScore.OpponentBreaks)
                {
                    b.AthleteID = person.ID;
                }
            }

            this.updateImages();
            this.listOfBreaksInMatchControl.Fill(this.MatchScore, this.MatchScore.FrameScores.IndexOf(this.CurrentFrameScore) + 1);
        }
Esempio n. 6
0
        async Task loadPeople(FullSnookerVenueData data)
        {
            if (data.Breaks == null || data.Matches == null)
            {
                data.People = null;
                return;
            }

            List <int> peopleIDs = new List <int>();

            List <int> peopleids1 = (from b in data.Breaks
                                     where b.AthleteID > 0
                                     select b.AthleteID).Distinct().ToList();
            List <int> peopleids2 = (from b in data.Breaks
                                     where b.OpponentAthleteID > 0
                                     select b.OpponentAthleteID).Distinct().ToList();
            List <int> peopleids3 = (from b in data.Matches
                                     where b.YourAthleteID > 0
                                     select b.YourAthleteID).Distinct().ToList();
            List <int> peopleids4 = (from b in data.Matches
                                     where b.OpponentAthleteID > 0
                                     select b.OpponentAthleteID).Distinct().ToList();

            peopleIDs.AddRange(peopleids1);
            foreach (var id in peopleids2)
            {
                if (peopleIDs.Contains(id) == false)
                {
                    peopleIDs.Add(id);
                }
            }
            foreach (var id in peopleids3)
            {
                if (peopleIDs.Contains(id) == false)
                {
                    peopleIDs.Add(id);
                }
            }
            foreach (var id in peopleids4)
            {
                if (peopleIDs.Contains(id) == false)
                {
                    peopleIDs.Add(id);
                }
            }

            await App.Cache.LoadFromWebserviceIfNecessary_People(peopleIDs);

            data.People = App.Cache.People.Get(peopleIDs);

            if (data.People != null)
            {
                foreach (var b in data.Breaks)
                {
                    PersonBasicWebModel person = b.AthleteID > 0 ? App.Cache.People.Get(b.AthleteID) : null;
                    if (person != null)
                    {
                        b.AthleteName = person.Name;
                    }
                    person = b.OpponentAthleteID > 0 ? App.Cache.People.Get(b.OpponentAthleteID) : null;
                    if (person != null)
                    {
                        b.OpponentName = person.Name;
                    }
                }
                foreach (var m in data.Matches)
                {
                    PersonBasicWebModel person = m.YourAthleteID > 0 ? App.Cache.People.Get(m.YourAthleteID) : null;
                    if (person != null)
                    {
                        m.YourName = person.Name;
                    }
                    person = m.OpponentAthleteID > 0 ? App.Cache.People.Get(m.OpponentAthleteID) : null;
                    if (person != null)
                    {
                        m.OpponentName = person.Name;
                    }
                }
            }
        }
Esempio n. 7
0
        async void userTapped(PersonBasicWebModel person, bool justRegistered)
        {
            if (string.IsNullOrEmpty(person.Name))
            {
                return;
            }
            if (this.alertAboutSettingsIfNecessary())
            {
                return;
            }

            if (person == personA)
            {
                this.activePlayerStatus = ActivePlayerStatusEnum.PlayerA;
                this.fillPickingAthletesPanel();
                return;
            }

            if (person == personB)
            {
                this.activePlayerStatus = ActivePlayerStatusEnum.PlayerB;
                this.fillPickingAthletesPanel();
                return;
            }

            if (justRegistered)
            {
                this.takePerson(person);
                return;
            }

            this.labelTitle.Text = "Please wait...";
            bool?hasPin = await App.WebService.HasPin(person.ID);

            this.labelTitle.Text = "";

            if (hasPin == false)
            {
                await this.DisplayAlert(person.Name, "This account does not have a PIN yet. Set the PIN in the 'Snooker Byb' app on your personal mobile device (under the 'Profile' page). Meanwhile you can proceed without the PIN.", "OK");

                this.takePerson(person);
                return;
            }

            if (hasPin == null)
            {
                await this.DisplayAlert("Byb", "No internet connection?", "OK");

                return;
            }

            EnterPinPage enterPinPage = new EnterPinPage(true);

            enterPinPage.TheTitle = person.Name;
            await this.Navigation.PushModalAsync(enterPinPage);

            enterPinPage.UserClickedCancel += () =>
            {
                this.Navigation.PopModalAsync();
            };
            enterPinPage.UserEnteredPin += async() =>
            {
                await this.Navigation.PopModalAsync();

                if (enterPinPage.IsPinOk == false)
                {
                    return;
                }

                this.labelTitle.Text = "Please wait...";
                bool?verified = await App.WebService.VerifyPin(person.ID, enterPinPage.Pin);

                this.labelTitle.Text = "";
                if (verified == false)
                {
                    await this.DisplayAlert("Byb", "Incorrect PIN", "OK");
                }
                else if (verified == null && App.WebService.IsLastExceptionDueToInternetIssues)
                {
                    await this.DisplayAlert("Byb", "Couldn't verify the PIN. Internet connection issues.", "OK");
                }
                else if (verified == null)
                {
                    await this.DisplayAlert("Byb", "Couldn't verify the PIN. Unspecified error.", "OK");
                }
                else
                {
                    this.takePerson(person);
                }
            };
        }
Esempio n. 8
0
 private void registerControl_UserRegistered(PersonBasicWebModel obj)
 {
     this.userTapped(obj, true);
     this.registerControl.Clear();
     this.PickingAthleteStatus = PickingAthleteStatusEnum.Existing;
 }