///// <summary> ///// Gets the alpha identifier. ///// </summary> //public string AlphaIdentifier { get; } ///// <summary> ///// Gets the current status of the unit. ///// </summary> //public override VehicleServiceType Status //{ // get // { // return this.ServiceTypeList[this.ServiceIndex]; // } //} ///// <summary> ///// Gets a collection containing all the enumerations in <see cref="VehicleServiceType"/>. ///// </summary> //public List<VehicleServiceType> ServiceTypeList => // Enum.GetValues(typeof(VehicleServiceType)). // Cast<VehicleServiceType>(). // ToList(); ///// <summary> ///// Gets or sets the index of the currently selected in service state from the ///// <see cref="ServiceTypeList"/> list of in service states. ///// </summary> //public int ServiceIndex //{ // get // { // return this.serviceIndex; // } // set // { // this.serviceIndex = value; // this.RaisePropertyChangedEvent(nameof(ServiceIndex)); // this.RaisePropertyChangedEvent(nameof(Status)); // } //} /// <summary> /// Refresh the units data. /// </summary> public void RefreshUnit() { this.JourneysList = new List <IJourneyViewModel>(); // TODO new each time. Really>? //Searcher searcher = new Searcher(); SearcherResults results = Searcher.RunCompleteSearch( this.DisplayUnitNumber, this.FormerNumbers.FormerNumbers); //List<IJourneyDetailsType> rawData = searcher.FoundJourneys; foreach (IJourneyDetailsType jny in results.FoundJourneys) { IJourneyViewModel journey = JourneyFactory.ToJourneyViewModel( jny, this.firstExamples, this.UnitNumber); this.AddJourney(journey); } this.UnitLastCheck = results.LastDateChecked; //this.RefreshUnitDistance(); this.CompleteUpdate(); this.SaveUnit(); }
/// <date>12/08/2018</date> /// <summary> /// Initialises a new instance of the <see cref="VehicleDetailsViewModel"/> class. /// </summary> /// <param name="rawData"> raw data, read from the file.</param> public VehicleDetailsViewModel( IndividualUnitFileContents rawData, FirstExampleManager firstExamples) { this.UnitNumber = rawData.UnitNumber; this.FormerNumbers = new VehicleNumberTypeViewModel(); this.m_lastCheckDate = rawData.LastCheckDate; this.FormerNumbers = rawData.FormerNumbers; this.Notes = rawData.Notes; foreach (IJourneyDetailsType jny in rawData.Journeys) { IJourneyViewModel journey = JourneyFactory.ToJourneyViewModel( jny, firstExamples, this.UnitNumber); this.AddJourney(journey); } this.origMilage = UnitDistance; for (int index = 0; index < this.ServiceTypeList.Count; ++index) { if (this.ServiceTypeList[index] == rawData.InService) { this.serviceIndex = index; break; } } }
/// ---------- ---------- ---------- ---------- ---------- ---------- /// <name>addJourney</name> /// <date>22/10/12</date> /// <summary> /// add journey /// </summary> /// <param name="newJourney">new journey</param> /// ---------- ---------- ---------- ---------- ---------- ---------- protected void AddJourney(IJourneyViewModel newJourney) { if (this.JourneysList == null) { this.JourneysList = new List <IJourneyViewModel>(); } //newJourney.ParentUnitNumber = this.UnitNumber; this.JourneysList.Insert(0, newJourney); }
/// <summary> /// Jnys for the selected day are loaded into the form. /// </summary> /// <returns>success flag</returns> private bool LoadJourneysForSelectedDay() { List <JourneyDetailsType> dayDetails = new List <JourneyDetailsType>(); string filePath = string.Empty; Logger logger = Logger.Instance; this.JnyList = new ObservableCollection <IJourneyViewModel>(); foreach (IJourneyDetailsType jny in DailyInputFactory.LoadDay(this.Date)) { IJourneyViewModel journey = JourneyFactory.ToJourneyViewModel( jny, this.firstExamples); this.JnyList.Add(journey); } this.RaisePropertyChangedEvent(nameof(this.JnyList)); return(true); }
/// <summary> /// Convert from a <see cref="IJourneyViewModel"/> to a <see cref="IJourneyDetailsType"/>. /// </summary> /// <param name="input"><see cref="IJourneyViewModel"/> to convert</param> /// <returns>converted <see cref="IJourneyDetailsType"/></returns> public static IJourneyDetailsType ToJourneyModel(IJourneyViewModel input) { List <string> units = new List <string>(); JourneyFactory.Add(units, input.UnitOne); JourneyFactory.Add(units, input.UnitTwo); JourneyFactory.Add(units, input.UnitThree); JourneyFactory.Add(units, input.UnitFour); IJourneyDetailsType model = new JourneyDetailsType( input.JnyId.Date, input.JnyId.JnyNumber, input.From, input.To, input.Route, input.Distance, units); return(model); }