Exemplo n.º 1
0
        internal void UpdateTimeAdjustments(IEnumerable <TimeAdjustmentViewModel> timeAdjustments)
        {
            var first = timeAdjustments.First();

            TimeAdjustments.RemoveAll(item => item.RouteBeginTime.RouteId == first.RouteBeginTime.RouteId &&
                                      item.RouteBeginTime.Id == first.RouteBeginTime.Id &&
                                      item.RouteBeginTime.RouteVariant == first.RouteBeginTime.RouteVariant &&
                                      item.RouteBeginTime.Days == first.RouteBeginTime.Days &&
                                      item.StationId == first.StationId);

            TimeAdjustments.AddRange(timeAdjustments);
            TimeAdjustmentsForSelection = timeAdjustments.ToList();
            OnPropertyChanged(nameof(TimeAdjustmentsForSelection));
        }
Exemplo n.º 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;
            }
        }