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); }
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; }
//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; }
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; }
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; }
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); } }