Exemplo n.º 1
0
        public int AddRecord(Models.Records rec)
        {
            int result = 0;

            result = ExInObj.AddRecord(rec);
            return(result);
        }
Exemplo n.º 2
0
        public Models.Records GetRecordByPilotId(long pilotId)
        {
            Models.Records        result = null;
            List <Models.Records> rank   = service.GetRecords();

            if (null != rank && rank.Count > 0)
            {
                result = rank.Where(x => x.PilotId == pilotId).FirstOrDefault();
            }
            return(result);
        }
Exemplo n.º 3
0
        public ActionResult Index(string city)
        {
            Models.Records rr = new Models.Records( );

            city = city.Trim( );                                                          //去除前後空格

            city = (city[0] == '台') ? city.Replace("台", "臺") : city;                      //把台換成臺(單引號是char雙引號是string)

            rr.location = r.location.Where(item => item.locationName == city).ToArray( ); //使用lamba來搜尋

            return(View(rr));
        }
Exemplo n.º 4
0
        public List <Models.AfterWinner> GetResultAfterWinner()
        {
            List <Models.AfterWinner> listAfter = null;
            List <Models.Records>     records   = GetRecords();

            if (null != records)
            {
                Models.Records winner = records.FirstOrDefault();

                listAfter = (from aw in records
                             select new Models.AfterWinner()
                {
                    PilotId = aw.PilotId,
                    PilotName = aw.PilotName,
                    TotalTime = aw.TotalTime,
                    TimeAfterWinner = (aw.TotalTime - winner.TotalTime)
                }).ToList();
            }
            return(listAfter);
        }
Exemplo n.º 5
0
        public ActionResult Index( )
        {
            //建立http連線
            using (HttpClient c = new HttpClient( )) {
                //基底網址uri
                c.BaseAddress = new Uri("https://opendata.cwb.gov.tw");

                //.NET 4.5需手動添加建立 SSL/TLS 的安全通道
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                //get,回傳HttpResponseMessage
                HttpResponseMessage response = c.GetAsync("/api/v1/rest/datastore/F-C0032-001?Authorization=CWB-422B0FA3-E374-492D-B54A-4D8942BE2B7E&format=JSON").Result;

                //以非同步作業方式將HTTP內容序列化為字串,回傳字串
                string result = response.Content.ReadAsStringAsync( ).Result;

                //將JSON格式轉換成物件並放入Models.Weather
                Models.Weather w = JsonConvert.DeserializeObject <Models.Weather>(result);
                r = w.records;
            }
            return(View(r));
        }