//SegmentActivities is a collection of Activities for each Segment on that DayEvent
        //public List<JSONActivity> SegmentActivities = new List<JSONActivity>();
        //public List<Segment> SegmentLeaderboard = new List<Segment>();

        public async Task <IActionResult> OnPostAsync()
        {
            //TODO: model should recognize if this button was clicked already
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            DayEventSegments = await _db.DayEventSegments
                               .Where(i => i.DayEventID == DayEventID)
                               .AsNoTracking()
                               .ToListAsync();

            //get club activities - limited to top 200
            List <JSONActivity> JSONActivities = await GetStravaActivities();

            //parse out activites with <Club.Keyword> in title
            JSONActivities = ParseActivities(JSONActivities);

            for (int x = 0; x < DayEventSegments.Count; x++)
            {
                //get Segment Leaderboard for list of segments
                RAWResults SegmentEntries = await GetSegmentEntries(DayEventSegments[x].SegmentID);

                //add efforts to Activity where usernames match between the segment and activity
                List <JSONActivity> Activities = AddSegmentEntries(SegmentEntries, JSONActivities);
                //save activities and athletes if new (to database)
                SaveActivities(Activities, DayEventSegments[x].SegmentID);
            }

            //TODO: only go to /leaderboard if there are no errors
            return(RedirectToPage("/Leaderboard", new { DayEventID }));
        }
        private List <JSONActivity> AddSegmentEntries(RAWResults segmentEntries, List <JSONActivity> activities)
        {
            //TODO: this logic only works when scope = 'today', because the matching algorithm on name is weak
            // and error prone over time

            // first place for segment gets 10 points
            int points      = 10;
            int rankCounter = 1;

            foreach (var segmentEntry in segmentEntries.Entries)
            {
                foreach (JSONActivity activity in activities)
                {
                    if ((segmentEntry.Athlete_name.ToLower().Equals(activity.Athlete.FirstName.ToLower() +
                                                                    " " + activity.Athlete.LastName.Substring(0, 1).ToLower() + ".")) &&
                        (activity.Start_date.Date == segmentEntry.Start_date.Date))
                    {
                        //TODO: MAJOR BUG!! because of horrible need to 'name' match between activity and leaderboard
                        // 2 scenarios exist that can create issues
                        // 1. a bad pattern name match removes a previously ADDED segmentEntry within an activity
                        // 2. a bad pattern name match adds a phantom entry when in fact the true rider didn't
                        //       ride on that segment
                        activity.Athlete.SegmentResults = new JSONResults()
                        {
                            Rank         = rankCounter,
                            Start_date   = segmentEntry.Start_date,
                            Elapsed_time = segmentEntry.Elapsed_time,
                            Strava_rank  = segmentEntry.Rank,
                            Points       = points
                        };
                        //each lower rank gets 2 less points
                        points = (points == 0) ? 0 : points - 2;
                        rankCounter++;
                        break;
                    }
                }
            }

            return(activities);
        }