예제 #1
0
        public IWholeShowScore GetScore(IGuessWholeShow master)
        {
            double correct     = 100;
            double incorrect   = -100;
            double correctSpot = 500;

            IWholeShowScore score = new WholeShowScore();

            SetService setService = new SetService(Ioc.GetInstance <ISetRepository>());

            var masterSet = (Set)setService.GetSet(master.SetId);

            foreach (var setSong in this.Set.SetSongs.OrderBy(x => x.Order))
            {
                int count = masterSet.SetSongs.Where(x => x.SongId == setSong.SongId).Count();

                //If they are just straight up wrong then add it to here
                if (count == 0)
                {
                    score.AddIncorrectSong(setSong.Song, incorrect);
                }
                else
                {
                    int masterCount  = masterSet.SetSongs.Where(x => x.SongId == setSong.SongId).Count();
                    int correctCount = score.Correct.Where(x => x.Key.SongId == setSong.SongId).Count();

                    if (masterCount > correctCount)
                    {
                        if (masterSet.SetSongs.Count >= setSong.Order)
                        {
                            if (setSong.Order == masterSet.SetSongs.Where(x => x.Order == setSong.Order).Single().Order)
                            {
                                //GIVE LOTS OF EXTRA POINTS CUZ THEY GOT IT IN THE SAME SLOT
                                score.AddCorrectSong(setSong.Song, correctSpot);
                            }
                            else
                            {
                                //GiVE NORMAL AMT OF POINTS CUZ THEY GOT WRONG SLOT
                                score.AddCorrectSong(setSong.Song, correct);
                            }
                        }
                        else
                        {
                            //GiVE NORMAL AMT OF POINTS CUZ THEY GOT WRONG SLOT
                            score.AddCorrectSong(setSong.Song, correct);
                        }
                    }
                    else
                    {
                        //If they guessed the song more times than is in the master setlist then they got it wrong
                        score.AddIncorrectSong(setSong.Song, incorrect);
                    }
                }
            }

            return(score);
        }
 public void SaveCommit(IGuessWholeShow guessWholeShow, out bool success)
 {
     using (IUnitOfWork uow = UnitOfWork.Begin())
     {
         Save(guessWholeShow, out success);
         if (success)
             uow.Commit();
     }
 }
        //make it delete any shows it is related to.  or not if you want those always kept.
        public void Delete( IGuessWholeShow guessWholeShow )
        {
            Checks.Argument.IsNotNull(guessWholeShow, "guessWholeShow");

            using (IUnitOfWork u = UnitOfWork.Begin())
            {
                _repo.Remove(guessWholeShow);
                u.Commit();
            }
        }
예제 #4
0
        //make it delete any shows it is related to.  or not if you want those always kept.
        public void Delete(IGuessWholeShow guessWholeShow)
        {
            Checks.Argument.IsNotNull(guessWholeShow, "guessWholeShow");

            using (IUnitOfWork u = UnitOfWork.Begin())
            {
                _repo.Remove(guessWholeShow);
                u.Commit();
            }
        }
예제 #5
0
        public IWholeShowScore GetScore(IGuessWholeShow master)
        {
            double correct = 100;
            double incorrect = -100;
            double correctSpot = 500;

            IWholeShowScore score = new WholeShowScore();

            SetService setService = new SetService(Ioc.GetInstance<ISetRepository>());

            var masterSet = (Set)setService.GetSet(master.SetId);

            foreach (var setSong in this.Set.SetSongs.OrderBy(x => x.Order))
            {
                int count = masterSet.SetSongs.Where(x => x.SongId == setSong.SongId).Count();

                //If they are just straight up wrong then add it to here
                if (count == 0)
                    score.AddIncorrectSong(setSong.Song, incorrect);
                else
                {
                    int masterCount = masterSet.SetSongs.Where(x => x.SongId == setSong.SongId).Count();
                    int correctCount = score.Correct.Where(x => x.Key.SongId == setSong.SongId).Count();

                    if (masterCount > correctCount)
                    {
                        if (masterSet.SetSongs.Count >= setSong.Order)
                        {
                            if (setSong.Order == masterSet.SetSongs.Where(x => x.Order == setSong.Order).Single().Order)
                            {
                                //GIVE LOTS OF EXTRA POINTS CUZ THEY GOT IT IN THE SAME SLOT
                                score.AddCorrectSong(setSong.Song, correctSpot);
                            }
                            else
                            {
                                //GiVE NORMAL AMT OF POINTS CUZ THEY GOT WRONG SLOT
                                score.AddCorrectSong(setSong.Song, correct);
                            }
                        }
                        else
                        {
                            //GiVE NORMAL AMT OF POINTS CUZ THEY GOT WRONG SLOT
                            score.AddCorrectSong(setSong.Song, correct);
                        }
                    }
                    else
                    {
                        //If they guessed the song more times than is in the master setlist then they got it wrong
                        score.AddIncorrectSong(setSong.Song, incorrect);
                    }
                }
            }

            return score;
        }
예제 #6
0
 public void SaveCommit(IGuessWholeShow guessWholeShow, out bool success)
 {
     using (IUnitOfWork uow = UnitOfWork.Begin())
     {
         Save(guessWholeShow, out success);
         if (success)
         {
             uow.Commit();
         }
     }
 }
        //consider changing the out parameter to a validation type object
        public void Save(IGuessWholeShow guessWholeShow, out bool success)
        {
            Checks.Argument.IsNotNull(guessWholeShow, "guessWholeShow");

            success = false;

            if (null == _repo.FindByGuessWholeShowId(guessWholeShow.GuessWholeShowId))
            {
                try
                {
                    _repo.Add(guessWholeShow);
                    success = true;
                }
                catch (Exception ex)
                {
                    success = false;
                }
            }
        }
예제 #8
0
        //consider changing the out parameter to a validation type object
        public void Save(IGuessWholeShow guessWholeShow, out bool success)
        {
            Checks.Argument.IsNotNull(guessWholeShow, "guessWholeShow");

            success = false;

            if (null == _repo.FindByGuessWholeShowId(guessWholeShow.GuessWholeShowId))
            {
                try
                {
                    _repo.Add(guessWholeShow);
                    success = true;
                }
                catch (Exception ex)
                {
                    success = false;
                }
            }
        }