Ejemplo n.º 1
0
        public void AddJudgeConflict(Int64 judge_id, Int64 conflict_id)
        {
            judge judge = GetJudgeFromID(judge_id);
            Int64 next_available_conflict = 0;

            if (judge.known_conflict1 == 0)
            {
                next_available_conflict = 1;
            }
            else if (judge.known_conflict2 == 0)
            {
                next_available_conflict = 2;
            }
            else if (judge.known_conflict3 == 0)
            {
                next_available_conflict = 3;
            }
            else if (judge.known_conflict4 == 0)
            {
                next_available_conflict = 4;
            }
            else if (judge.known_conflict5 == 0)
            {
                next_available_conflict = 5;
            }
            else if (judge.known_conflict6 == 0)
            {
                next_available_conflict = 6;
            }
            else if (judge.known_conflict7 == 0)
            {
                next_available_conflict = 7;
            }
            else if (judge.known_conflict8 == 0)
            {
                next_available_conflict = 8;
            }
            else if (judge.known_conflict9 == 0)
            {
                next_available_conflict = 9;
            }
            else if (judge.known_conflict10 == 0)
            {
                next_available_conflict = 10;
            }
            if (next_available_conflict == 0)
            {
                Exception ex = new Exception("Too many team conflicts to add another");
                throw ex;
            }
            String query = String.Format("UPDATE judges SET known_conflict{0} = {1} WHERE id = {2}", next_available_conflict, conflict_id, judge.id);

            using (SQLiteCommand command = new SQLiteCommand(query, connection))
            {
                command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 2
0
        public judge GetJudgeFromID(Int64 id)
        {
            String query = String.Format("SELECT * FROM judges where id = {0} LIMIT 1", id);

            using (SQLiteCommand command = new SQLiteCommand(query, connection))
            {
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        judge judge = ReaderToJudge(reader);
                        return(judge);
                    }
                }
            }
            return(new judge());
        }
Ejemplo n.º 3
0
        public List <judge> GetJudges(Int64 round = 0)
        {
            List <judge> judges = new List <judge>();
            String       query  = round == 0 ? "SELECT * FROM judges" : String.Format("SELECT * FROM judges WHERE active_round_{0} = 1", round);

            using (SQLiteCommand command = new SQLiteCommand(query, connection))
            {
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        judge judge = ReaderToJudge(reader);
                        judges.Add(judge);
                    }
                }
            }
            return(judges);
        }