Example #1
0
        public CurrentTeamRiddleViewModel BuildRiddleForTeam(string teamName)
        {
            var teamQuest = getTeamQuest(teamName);
            if (teamQuest == null)
                return null;
            var currentTeamRiddle = new CurrentTeamRiddleViewModel();

            RiddleModel currentRiddle = getCurrentRiddle(teamQuest);

            currentTeamRiddle.Id = currentRiddle.Id;
            currentTeamRiddle.IsTheEnd = teamQuest.IsTheEnd;
            currentTeamRiddle.TeamEmail = teamQuest.Team.Email;

            currentTeamRiddle.TeamName = teamQuest.Team.Name;

            currentTeamRiddle.RiddleText = currentRiddle.Text;

            currentTeamRiddle.RiddleNumber = teamQuest.GetCurrentRiddleNumber();

            TimeSpan nextPromptTime;

            currentTeamRiddle.Prompts = teamQuest.GetCurrentPromptList(out nextPromptTime);

            currentTeamRiddle.NextPrompTime = string.Format("{0:hh\\:mm\\:ss}", nextPromptTime);

            return currentTeamRiddle;
        }
Example #2
0
        public bool IsRiddleCodeCorrect(CurrentTeamRiddleViewModel model)
        {
            var teamQuest = getTeamQuest(model.TeamName);
            var isCodeCorrect = teamQuest.Riddle.Code.ToLower() == model.Code.ToLower();
            var isRiddleSame = teamQuest.Riddle.Id == model.Id;

            return isCodeCorrect && isRiddleSame;
        }
Example #3
0
 public bool IfRiddleCodeCorrectNextRiddle(CurrentTeamRiddleViewModel model)
 {
     lock (_lock)
     {
         if (IsRiddleCodeCorrect(model))
         {
             nextRiddle(model);
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Example #4
0
 private void nextRiddle(CurrentTeamRiddleViewModel model)
 {
     var teamQuest = getTeamQuest(model.TeamName);
     var statisticsService = new StatisticsService();
     if (teamQuest.HasNextRiddle())
     {
         var nextRiddle = teamQuest.NextRiddle();
         teamQuest.RiddleId = nextRiddle.Id;
         teamQuest.RiddleStarTime = DateTime.Now;
         dbQuest.Entry(teamQuest).State = EntityState.Modified;
         dbQuest.SaveChanges();
         statisticsService.UpdateStatictics(model.TeamName);
     }
     else
     {
         teamQuest.IsTheEnd = true;
         dbQuest.Entry(teamQuest).State = EntityState.Modified;
         dbQuest.SaveChanges();
         statisticsService.Finish(model.TeamName);
     }
 }