Exemple #1
0
 public List<Result> getAllResultsByRound(Round round)
 {
     var result = (from r in dc.Results
                   where r.FK_Round== round.Round_Id
                   select r).ToList<Result>();
     return result;
 }
Exemple #2
0
 public List<Question> getAllQuestions(Round round)
 {
     if (round == null)
     {
         throw new Exception("Round must be given...");
     }
     var result = (from q in dc.Questions
                   where q.FK_Round == round.Round_Id
                   select q).ToList<Question>();
     return result;
 }
Exemple #3
0
        public void setRound(Round rnd)
        {
            round = rnd;

            //clear the lists and recreate the values
            playableQuestions.Clear();
            List<Question> questions = gm.getAllQuestions(round);
            foreach (Question q in questions)
            {
                playableQuestions.Add(new PlayableQuestion(q));
            }
        }
Exemple #4
0
        public PlayableRound(Round rnd)
        {
            //select the round
            round = rnd;
            if (round.Round_started != null)
            {
                DateTime maxTime = (DateTime)round.Round_started;
                maxTime = maxTime.AddSeconds((double)round.Max_Time);
                DateTime currentTime = DateTime.Now;
                isActive = (round.Round_started <= currentTime && currentTime < maxTime);
            }

            //get the questions and create playable questions
            List<Question> questions = gm.getAllQuestions(round);
            foreach(Question q in questions)
            {
                playableQuestions.Add(new PlayableQuestion(q));
            }
        }
Exemple #5
0
 public Round getRoundByName(Round round)
 {
     if (round == null)
     {
         throw new Exception("Round must be given...");
     }
     var result = (from r in dc.Rounds
                   where r.Round_name == round.Round_name
                   select r).SingleOrDefault();
     return (Round)result;
 }
Exemple #6
0
        public int updateRound(Round round)
        {
            //query naar database om waarde te vinden
            Round result = (from r in dc.Rounds
                           where r.Round_Id == round.Round_Id
                           select r).Single();

            //veranderingen aanbrengen
            if (round.FK_Quiz != null) result.FK_Quiz = round.FK_Quiz;
            if (round.Max_Time != null) result.Max_Time = round.Max_Time;
            if (round.Round_name != null) result.Round_name = round.Round_name;

            //updaten in db
            try
            {
                dc.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception("Value couldn't be updated...");
            }

            return result.Round_Id;
        }
Exemple #7
0
        public Round stopRound(Round round)
        {
            //stop de ronde
            Round result = (from r in dc.Rounds
                            where r.Round_Id == round.Round_Id
                            select r).SingleOrDefault();

            TimeSpan maxTime = (TimeSpan)(DateTime.Now - result.Round_started);
            result.Max_Time = (int)maxTime.TotalSeconds;

            //updaten in db
            try
            {
                dc.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception("Value couldn't be updated...");
            }

            return result;
        }
Exemple #8
0
        public int insertRound(Round r)
        {
            dc.Rounds.InsertOnSubmit(r);
            try
            {
                dc.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception("Query couldn't be executed...");
            }

            return r.Round_Id;
        }
        private Round selectRound(String id)
        {
            GameModel gm = new GameModel();
            Round round = new Round();
            //kijk of de quiz gegeven is, anders gaan we de status aanpassen naar "no quiz given"
            int roundId;
            String status;
            try
            {
                roundId = int.Parse(id);
                try
                {
                    round.Round_Id = roundId;
                    round = gm.getRound(round);
                    status = "success";
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    status = "no round given";
                }
            }
            catch (Exception e)
            {
                //als we hier terechtkomen is de id een textuele string (bv. "abc")
                try
                {
                    round.Round_name = id;
                    round = gm.getRoundByName(round);
                    status = "success";
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    status = "no round given";
                }
            }

            if (status != "success")
            {
                return new Round();
            }
            else
            {
                return round;
            }
        }
 partial void DeleteRound(Round instance);
 partial void UpdateRound(Round instance);
 partial void InsertRound(Round instance);
		private void detach_Rounds(Round entity)
		{
			this.SendPropertyChanging();
			entity.Quiz = null;
		}
		private void attach_Rounds(Round entity)
		{
			this.SendPropertyChanging();
			entity.Quiz = this;
		}