Esempio n. 1
0
        /// <summary>
        /// Responds to an ajax request containing either a list of greyhound names and starting traps (1 race) or a string with many \n seperated greyhound names in the format "1 Vegas Gold".
        /// Since these lists are going to a dummy score calc for the moment, **traps are ignored**.
        /// TODO: Runner can be changed to include a greyhound object thus preserving the trap value.
        /// </summary>
        /// <param name="runners"></param>
        /// <param name="m_runners"></param>
        /// <returns></returns>
        public ActionResult GetPredictions(List<Runner> runners, RaceMeetRunners m_runners)
        {
            List<List<Greyhound>> allRunners = GetMultipleRaceRunners(m_runners);
            List<Greyhound> singleRace = GetSingleRaceRunners(runners);

            scoreCalc sc = new scoreCalc();
            if (allRunners == null)
            {
                allRunners = new List<List<Greyhound>>();
                allRunners.Add(singleRace);
            }
            return Json(sc.GetScores(allRunners));
        }
Esempio n. 2
0
        private List<List<Greyhound>> GetMultipleRaceRunners(RaceMeetRunners m_runners)
        {
            if (string.IsNullOrEmpty(m_runners.multipleRace_Runners))
            {
                return null;
            }

            string[] p = m_runners.multipleRace_Runners.Split('\n'); //split the string into a list
            var query = from r in p
                        where !string.IsNullOrEmpty(r) //remove any empty list elements
                        select r;
            List<Runner> q = new List<Runner>();

            foreach (var item in query.Reverse()) //need to reverse the ordering on the linq query so they end up in the stack in the correct order (otherwise the last runner of the evening in
            {                                     //trap 6 will be at the top
                string[] r = item.Split(' ');
                q.Add(new Runner { Trap = int.Parse(_utils.RemoveLetters(item)), Name = _utils.RemoveNumbers(item).Trim() });
            }
            Stack<Runner> s = new Stack<Runner>(q);
            List<List<Greyhound>> g = new List<List<Greyhound>>();
            return DivideRaces(s, g);
        }