コード例 #1
0
ファイル: Program.cs プロジェクト: farmerajf/buser
        static void Main(string[] args)
        {
            while (true)
            {
                var route = new List<string>
                {
                    "0170SGA10050",
                    "0170SGA10049",
                    "0170SGB20001",
                    "0170SGB20002",
                    "0170SGB20003"
                };

                var tracker = new Buser();

                foreach (var stop in route)
                {
                    Console.WriteLine("Stop: " + stop);

                    var arrivals = tracker.GetBuses(stop);
                    foreach (var arrival in arrivals)
                    {
                        Console.WriteLine("{0} | {1}mins", arrival.Code, arrival.MinutesToArrival);
                    }
                    Console.WriteLine();
                }

                Console.ReadLine();
                Console.Clear();
            }
        }
コード例 #2
0
ファイル: BuserController.cs プロジェクト: farmerajf/buser
        // GET api/values/5
        public string Get(string id, string apiKey)
        {
            if (apiKey != ConfigurationManager.AppSettings["ApiKey"])
            {
                var error = new {Error = "Invalid API key"};
                var errorJson = new JavaScriptSerializer().Serialize(error);
                return errorJson;
            }

            var buser = new Buser();
            var buses = buser.GetBuses(id);

            var json = new JavaScriptSerializer().Serialize(buses);
            return json;
        }