Beispiel #1
0
        public ScoreModel getScore(int id)
        {
            ScoreDataService scoreDS = new ScoreDataService();
            ScoreModel       score   = scoreDS.Read(id);

            AccountDataService accountDS = new AccountDataService();

            score.UserName = accountDS.Read(score.UserId).UserName;

            return(score);
        }
Beispiel #2
0
        public bool saveScore(ScoreModel score)
        {
            ScoreDataService ds = new ScoreDataService();

            if (ds.Create(score))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        public List <ScoreModel> getAllScores()
        {
            ScoreDataService  scoreDS = new ScoreDataService();
            List <ScoreModel> scores  = scoreDS.ReadAll();

            AccountDataService accountDS = new AccountDataService();

            foreach (ScoreModel score in scores)
            {
                score.UserName = accountDS.Read(score.UserId).UserName;
            }

            return(scores);
        }
Beispiel #4
0
        public List <IEnumerable <ScoreModel> > getHighScores()
        {
            ScoreDataService  scoreDS = new ScoreDataService();
            List <ScoreModel> scores  = scoreDS.ReadAll();

            AccountDataService accountDS = new AccountDataService();

            foreach (ScoreModel score in scores)
            {
                score.UserName = accountDS.Read(score.UserId).UserName;
            }

            List <IEnumerable <ScoreModel> > highScores = new List <IEnumerable <ScoreModel> >();

            var highScoresEasy =
                (from score in scores
                 where score.Difficulty == 0
                 orderby score
                 select score).Take(5);

            highScores.Add(highScoresEasy);

            var highScoresMedium =
                (from score in scores
                 where score.Difficulty == 1
                 orderby score
                 select score).Take(5);

            highScores.Add(highScoresMedium);

            var highScoresHard =
                (from score in scores
                 where score.Difficulty == 2
                 orderby score
                 select score).Take(5);

            highScores.Add(highScoresHard);

            return(highScores);
        }