예제 #1
0
파일: train.cs 프로젝트: osuraw/TrainFinder
        public static async Task <List <Train> > GetTrains()
        {
            var tempData = await WebConnect.GetData("Trains");

            var results = JsonConvert.DeserializeObject <IEnumerable <Train> >(tempData);
            var trains  = new List <Train>()
            {
                new Train()
                {
                    Name = "Select Train", TID = 0
                }, new Train()
                {
                    Name = "All Trains", TID = 1
                }
            };

            foreach (var result in results)
            {
                var temp = new Train
                {
                    RID          = result.RID,
                    TID          = result.TID,
                    Name         = result.Name,
                    StartStation = result.StartStation,
                    EndStation   = result.EndStation,
                    Description  = result.Description
                };
                trains.Add(temp);
            }
            return(trains);
        }
예제 #2
0
파일: train.cs 프로젝트: osuraw/TrainFinder
        private static async Task GetTrain(int id)
        {
            var tempData = await WebConnect.GetData("Train/GetTrainInRoute/" + id);

            var results = JsonConvert.DeserializeObject <IEnumerable <Train> >(tempData);
            var trains  = new ObservableCollection <Train>()
            {
                new Train()
                {
                    Name = "Select Train"
                }
            };

            foreach (var result in results)
            {
                var temp = new Train
                {
                    RID          = result.RID,
                    TID          = result.TID,
                    Name         = result.Name,
                    StartStation = result.StartStation,
                    EndStation   = result.EndStation,
                    Description  = result.Description
                };
                trains.Add(temp);
            }
            Trains = trains;
        }
예제 #3
0
파일: route.cs 프로젝트: osuraw/TrainFinder
        //private static async Task<ObservableCollection<Route>> GetRouteList1()
        private static async Task GetRouteList1()
        {
            //var tempData = WebConnect.GetData("Route/GetRouteList");
            var tempData = await WebConnect.GetData("Route/GetRouteList");

            var results = JsonConvert.DeserializeObject <IEnumerable <Route> >(tempData);
            //---------------------------------------------------------------------
            var routes = new ObservableCollection <Route>()
            {
                new Route {
                    RID = 0, Name = "Select Route"
                }
            };

            foreach (var result in results)
            {
                var temp = new Route
                {
                    RID          = result.RID,
                    Name         = result.Name,
                    Distance     = result.Distance,
                    StartStation = result.StartStation,
                    EndStation   = result.EndStation,
                    Description  = result.Description
                };
                routes.Add(temp);
            }

            Routes = routes;
            //return routes;
        }
예제 #4
0
        private static async Task GetStationBy(int id)
        {
            var tempData = await WebConnect.GetData("Stations/GetStationInRoute/" + id);

            var results  = JsonConvert.DeserializeObject <IEnumerable <Station> >(tempData);
            var stations = new ObservableCollection <Station> {
                new Station()
                {
                    Name = "Select Station"
                }
            };

            foreach (var result in results)
            {
                var temp = new Station
                {
                    SID       = result.SID,
                    Name      = result.Name,
                    Distance  = result.Distance,
                    Location  = result.Location,
                    Address   = result.Address,
                    Telephone = result.Telephone,
                    RID       = result.RID
                };
                stations.Add(temp);
            }
            //could make error
            Stations = stations;
        }
예제 #5
0
        private static async Task GetLocations(short routeId)
        {
            var tempData = await WebConnect.GetData("PinLocation/GetPinLocation?rid=" + routeId);

            var results      = JsonConvert.DeserializeObject <IEnumerable <PinLocation> >(tempData);
            var locationList = new ObservableCollection <PinLocation>();

            foreach (var result in results)
            {
                locationList.Add(result);
            }
            PinLocations = locationList;
        }
예제 #6
0
        private static async Task GetTimeTable(byte flag, int id)
        {
            var tempData = await WebConnect.GetData($"TimeTables/GetTimeTableByTypeId?type={flag}&id={id}");

            var results = JsonConvert.DeserializeObject <IEnumerable <Stops> >(tempData);

            StopList = new ObservableCollection <Stops>();
            foreach (var result in results)
            {
                var temp = new Stops
                {
                    TrainId       = result.TrainId,
                    StationId     = result.StationId,
                    TrainName     = result.TrainName,
                    StationName   = result.StationName,
                    Direction     = result.Direction,
                    ArriveTime    = result.ArriveTime.TimeToString(),
                    DepartureTime = result.DepartureTime.TimeToString()
                };
                StopList.Add(temp);
            }
        }