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)); }
internal string GetScheduleDataString() { var schedule = new ScheduleData(); schedule.BusServices.AddRange(BusServices); schedule.BusStations.AddRange(BusStations); schedule.Routes.AddRange(Routes); schedule.RoutesDetails.AddRange(GetRoutesDetails(RouteDetails)); schedule.RoutesBeginTimes.AddRange(RouteBeginTimes); schedule.TimeAdjustments.AddRange(TimeAdjustments.Select(item => new StationTimeAdjustment { BeginTimeId = item.RouteBeginTime.Id, RouteId = item.RouteBeginTime.RouteId, RouteVariantId = item.RouteBeginTime.RouteVariant, StationId = item.StationId, TimeAdjustmentMin = (int)item.TimeAdjustment.TotalMinutes, Days = item.RouteBeginTime.Days })); return(JsonConvert.SerializeObject(schedule)); }
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; } }
internal void OnRouteStationChanged(BusRoute route, int routeVariant, RouteBeginTime.ScheduleDays scheduleDays, RouteStationViewModel stationViewModel) { TimeAdjustmentsForSelection = TimeAdjustments.Where(item => item.RouteBeginTime.RouteId == route.Id && item.RouteBeginTime.RouteVariant == routeVariant && item.RouteBeginTime.Days == scheduleDays && item.StationId == stationViewModel.BusStation.Id).ToList(); OnPropertyChanged(nameof(TimeAdjustmentsForSelection)); }
internal IEnumerable <TimeAdjustmentViewModel> GetTimeAdjustmentsForRouteVariant(BusRoute route, int routeVariant, RouteBeginTime.ScheduleDays scheduleDays) { return(TimeAdjustments.Where(item => item.RouteBeginTime.RouteId == route.Id && item.RouteBeginTime.RouteVariant == routeVariant && item.RouteBeginTime.Days == scheduleDays)); }