Exemple #1
0
 internal void AddRouteDetails(List <RouteStationViewModel> routeDetails)
 {
     RouteDetails.RemoveAll(item => item.RouteId == routeDetails[0].RouteId && item.RouteVariantId == routeDetails[0].RouteVariantId);
     RouteDetails.AddRange(routeDetails);
     RouteDetailsForRoute = routeDetails;
     OnPropertyChanged(nameof(RouteDetailsForRoute));
 }
Exemple #2
0
        internal void Setup(string jsonData)
        {
            try
            {
                BusServices.Clear();
                _theSchedule = JsonConvert.DeserializeObject <ScheduleData>(jsonData);
                foreach (var service in _theSchedule.BusServices)
                {
                    BusServices.Add(service);
                }

                BusStations.Clear();
                foreach (var station in _theSchedule.BusStations)
                {
                    BusStations.Add(station);
                }
                Routes.Clear();
                Routes.AddRange(_theSchedule.Routes);

                RouteDetails.Clear();
                RouteDetails.AddRange(_theSchedule.RoutesDetails.Select(rd => new RouteStationViewModel {
                    RouteId = rd.BusRouteId, BusStation = BusStations.FirstOrDefault(BusStopSchedule => BusStopSchedule.Id == rd.BusStopId), OrderNum = rd.OrderNum, TimeDiff = rd.TimeDiff, RouteVariantId = rd.RouteVariant
                }));

                RouteBeginTimes.Clear();
                RouteBeginTimes.AddRange(_theSchedule.RoutesBeginTimes);

                TimeAdjustments.Clear();
                TimeAdjustments.AddRange(_theSchedule.TimeAdjustments.Select(adj => new TimeAdjustmentViewModel(RouteBeginTimes.First(rbt => rbt.RouteId == adj.RouteId && rbt.RouteVariant == adj.RouteVariantId && rbt.Id == adj.BeginTimeId && rbt.Days == adj.Days), TimeSpan.FromMinutes(adj.TimeAdjustmentMin), adj.StationId)));

                OnPropertyChanged(nameof(BusServices));
                OnPropertyChanged(nameof(BusStations));
            }
            catch (Exception exc)
            {
                var msg = exc.Message;
            }
        }