Example #1
0
        private void PostScore_Clicked(object sender, EventArgs e)
        {
            var score       = new Scores();
            var selectedtee = (PickerTee)TeePicker.SelectedItem;
            var teeinfo     = App.Database.GetTeeInfo(selectedtee.InfoID);

            score.Score     = int.Parse(EnteredScore.Text);
            score.InfoID    = teeinfo.InfoID;
            score.Date      = ScoreDate.Date;
            score.RoundType = SelectedRoundType.SelectedItem.ToString();
            if (score.RoundType == "18")
            {
                score.Differential = Math.Round((score.Score - teeinfo.Rating) * 113 / teeinfo.Slope, 2);
            }
            else if (score.RoundType == "Front")
            {
                var slope = teeinfo.Slope;
                if (teeinfo.FrontSlope > 0)
                {
                    slope = teeinfo.FrontSlope;
                }
                score.Differential = Math.Round((score.Score - teeinfo.FrontRating) * 113 / slope, 2);
            }
            else if (score.RoundType == "Back")
            {
                //some courses dont have a back rating so need to remove the back rating setting if they dont
                var slope = teeinfo.Slope;
                if (teeinfo.BackSlope > 0)
                {
                    slope = teeinfo.BackSlope;
                }
                score.Differential = Math.Round((score.Score - teeinfo.BackRating) * 113 / slope, 2);
            }
            score.PlayedID = selectedcourse.PlayedID;
            App.Database.SaveScore(score);
            App.Database.CalculateHandicap(score.RoundType);
            SelectedRoundType.SelectedIndex = 0;

            PopupNavigation.Instance.PopAllAsync();
            ((App.Current.MainPage as MasterDetailPage).Detail as NavigationPage).Navigation.PushAsync(new MyScores());
            (App.Current.MainPage as MasterDetailPage).IsPresented = false;
        }
Example #2
0
 public int UpdateScore(Scores score)
 {
     return(_database.Update(score));
 }