Example #1
0
		// GET api/<controller>
		public IEnumerable<Player> Get()
		{
			using (var db = new TennisDb())
			{
				return db.Players.ToArray();
			}
		}
Example #2
0
        // GET api/matches
        public IEnumerable<MatchRaw> Get()
        {
					using (var db = new TennisDb())
					{
						return db.Matches.ToArray();
					}
				}
Example #3
0
		public MatchController()
		{
			using (var db = new TennisDb())
			{
				PlayerList = db.Players.ToArray();
			}
			//using (var dr = TennisObjects.DataAccess.GetAllPlayers())
			//	PlayerList = TennisObjects.Player.GetList(dr);
		}
Example #4
0
		// GET api/<controller>/5
		public Player Get(int id)
		{
			using (var db = new TennisDb())
			{
				var query = from p in db.Players where p.Id == id select p;
				if (!query.Any())
				{
					//need to throw a 404 exception
					//return HttpStatusCode.NotFound;
				}
				return query.First();
			}
		}
Example #5
0
        // GET api/matches/5
        public MatchRaw Get(int id)
        {
					using (var db = new TennisDb())
					{
						var query = from item in db.Matches where item.ID == id select item;
						if (!query.Any())
						{
							//need to throw a 404 exception
							//return HttpStatusCode.NotFound;
						}
						return query.First();
					}
				}
Example #6
0
		public static void PrintMatches()
		{
			TennisDb db = new TennisDb();
			TennisDb dbPlayer = new TennisDb();

			Console.WriteLine();
			foreach (var matchRaw in db.Matches)
			{
				var match = matchRaw.ToMatch();
				var playerMatch = match.ToPlayerMatch(1);
				var opponent = dbPlayer.Players.Find(playerMatch.OpponentID);
				//Console.Write(match.ToString().PadRight(80));
				//Console.WriteLine(playerMatch.ToString());
				//Console.WriteLine("{0} Player {1} d. Player {2} {3}-{4} {5}-{6} {7}-{8}{9}", match.Date, playerMatch.OpponentName, match.Score, match.Defaulted ? " default" : "");
				Console.WriteLine("{0},{1},{2},{3}", match.Date, opponent.FullName, playerMatch.Result, playerMatch.Score);
			}
		}