Ejemplo n.º 1
0
        public int UpdateThreshold(int lenght, int players)
        {
            var current = _thresholds.Where(t => t.Players == players).FirstOrDefault();

            if (current != null)
            {
                return(current.UpdateThreshold(lenght));
            }
            else
            {
                var newList = new List <int> {
                    lenght
                };
                var newThreshold = new ThresholdData(newList, players);
                _thresholds.Add(newThreshold);
                return(lenght);
            }
        }
Ejemplo n.º 2
0
        public ThresholdService(ScoreBoardContext context)
        {
            _context = context;

            _thresholds = new List <ThresholdData>();

            //get number of players
            var q = (from a in _context.Scores
                     group a by a.Players into playergroups
                     select playergroups.Key).ToList();

            //setup thresholds
            foreach (var numberofplayers in q)
            {
                var currentlist = _context.Scores.Where(p => p.Players == numberofplayers).OrderByDescending(r => r.Lenght).Take(10).Select(r => r.Lenght).ToList();
                var current     = new ThresholdData(currentlist, numberofplayers);
                _thresholds.Add(current);
            }
        }