public async Task Repeat()
        {
            ServiceId       = SelectedService.Id;
            ServiceTemplate = ServiceTemplateDataAccess.GetServiceTemplateById(SelectedService.ServiceTemplateId);
            ReviewServicesViewModel reviewVM = IoC.Get <ReviewServicesViewModel>();

            for (int i = 0; i < RepeatCount; i++)
            {
                var newService = new ServiceModel();
                newService.ServiceTemplateId = ServiceTemplate.Id;
                newService.ServiceName       = SelectedService.ServiceName;
                newService.StartTime         = SelectedService.StartTime + (i + 1) * TimeOffset;
                newService.EndTime           = SelectedService.EndTime + (i + 1) * TimeOffset;
                int    serviceNumber = NumberStart + i * NumberOffset;
                string offset        = serviceNumber.ToString($"D{Digits}");
                newService.ServiceAbbreviation = $"{ServiceTemplate.ServiceTemplateAbbreviation}{Separator}{offset}";
                reviewVM.CreatedServices.Add(newService);
            }

            reviewVM.CreatedServices = new BindableCollection <ServiceModel>(reviewVM.CreatedServices.OrderBy(x => x.StartTime));
            await _windowManager.ShowDialogAsync(reviewVM);

            if (reviewVM.IsSaved)
            {
                ServiceList = new BindableCollection <ServiceModel>(ServicesDataAccess
                                                                    .GetServicesPerRoute(RouteId).OrderBy(x => x.StartTime));
                NotifyOfPropertyChange(() => ServiceList);
            }
            NotifyOfPropertyChange(() => CanRepeat);
        }
 public void EditService()
 {
     ServiceName         = SelectedService.ServiceName;
     ServiceAbbreviation = SelectedService.ServiceAbbreviation;
     ServiceTemplate     = ServiceTemplateDataAccess.GetServiceTemplateById(SelectedService.ServiceTemplateId);
     ServiceId           = SelectedService.Id;
     StartTimeText       = TimeConverters.MinutesToString(SelectedService.StartTime);
     EndTimeText         = TimeConverters.MinutesToString(SelectedService.EndTime);
     NotifyOfPropertyChange(() => CanEditService);
     NotifyOfPropertyChange(() => CanSaveService);
     NotifyOfPropertyChange(() => CanRepeat);
 }
        protected override async void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);
            TimeEvents.SelectedRoute   = RouteDataAccess.GetRouteById(RouteId);
            TimeEvents.SelectedService = ServiceTemplateDataAccess.GetServiceTemplateById(ServiceId);
            TimeEvents.LocationList    = new BindableCollection <LocationModel>(LocationDataAccess.GetAllLocationsPerRoute(RouteId));
            var temp = FullTimeEventDataAccess.GetAllFullTimeEventsPerServiceTemplate(ServiceId)
                       .OrderBy(p => p.Order)
                       .ToList();

            TimeEvents.FilteredFullTimeEventList = new BindableCollection <FullTimeEventModel>(temp);
            TimeEventTypeList = TimeEventTypeDataAccess.GetAllTimeEventTypeStrings();
            NotifyOfPropertyChange(() => TimeEventTypeList);
            NotifyOfPropertyChange(() => TimeEvents);
        }
示例#4
0
        private void PrepareDataSet()
        {
            TimeGraphUI      = new ObservableCollection <TimeGraphUIModel>();
            ServiceClassList = ServiceClassDataAccess.GetAllServiceClasses();
            var serviceList = new ObservableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(TimetableId));

            foreach (var service in serviceList)
            {
                var item = new TimeGraphUIModel();
                var serviceTemplateId = service.ServiceTemplateId;
                var serviceTemplate   = ServiceTemplateDataAccess.GetServiceTemplateById(serviceTemplateId);
                item.TimeEventList       = new BindableCollection <ExtendedFullTimeEventModel>(FullTimeEventDataAccess.GetAllExtendedFullTimeEventsPerServiceTemplate(serviceTemplateId));
                item.ServiceName         = service.ServiceName;
                item.ServiceAbbreviation = service.ServiceAbbreviation;
                item.ServiceType         = serviceTemplate.ServiceType;
                item.StartTimeText       = service.StartTimeText;
                item.EndTimeText         = service.EndTimeText;
                int actualTime = service.StartTime;
                foreach (var fullTimeEvent in item.TimeEventList)
                {
                    actualTime += fullTimeEvent.ArrivalTime;
                    fullTimeEvent.ArrivalTimeText = TimeConverters.MinutesToString(actualTime);
                    DataPoint point = GetFirstDataPoint(fullTimeEvent, actualTime);
                    item.DataLine.Add(point);
                    if (fullTimeEvent.WaitTime > 0)
                    {
                        actualTime += fullTimeEvent.WaitTime;
                        DataPoint point2 = GetSecondDataPoint(actualTime, point.X);
                        item.DataLine.Add(point2);
                    }
                    fullTimeEvent.DepartureTimeText = TimeConverters.MinutesToString(actualTime);
                }
                TimeGraphUI.Add(item);
            }
            OnPropertyChanged("TimeGraphUI");
        }