Example #1
0
        /*
         * Searches for tournament.
         */
        private Pair FindTournament(int id)
        {
            // id must be correct
            if (id <= 0)
            {
                return new Pair();
            }

            // Search for tournament with this id
            var tournament = db.Tournaments.Find(id);
            if (tournament == null)
            {
                return new Pair();
            }

            // Store tournament in Pair model
            Pair pair = new Pair { Tournament = tournament};
            return pair;
        }
Example #2
0
        // GET: /Pair/
        public ActionResult Index()
        {
            var results = from c in db.Pairs
                        join d in db.Teams on c.Team1.ID equals d.ID
                        join e in db.Teams on c.Team2.ID equals e.ID
                        join tourn in db.Tournaments on c.Tournament.ID equals tourn.ID
                        select new
                        {
                            c.ID,
                            Team1 = d,
                            Team2 = e,
                            c.Team1Scored,
                            c.Team2Scored,
                            Tournament = tourn
                        };

            var pairs = new List<Pair>();
            foreach (var result in results)
            {
                Pair pair = new Pair();
                pair.ID = result.ID;
                pair.Team1 = result.Team1;
                pair.Team2 = result.Team2;
                pair.Team1Scored = result.Team1Scored;
                pair.Team2Scored = result.Team2Scored;
                pair.Tournament = result.Tournament;
                pairs.Add(pair);
            }

            return View(pairs);
        }