public bool SortMovingTrams(TramLocation location) { SortingAlgoritm sorter = new SortingAlgoritm(AllTracks, repo); List <Tram> movingTrams = repo.GetAllTramsWithLocation(location); if (movingTrams.Count != 0) { for (int i = 0; i < movingTrams.Count; i++) { BeheerTram beheerTram = BeheerTram.ToBeheerTram(movingTrams[i]); if (location == TramLocation.ComingIn) { if (movingTrams[i].DepartureTime == null) { GetExitTime(beheerTram); } SortTram(sorter, beheerTram); } else if (location == TramLocation.GoingOut) { beheerTram.EditTramLocation(TramLocation.Out); movingTrams[i] = beheerTram; repo.EditTram(movingTrams[i]); repo.WipeSectorByTramId(movingTrams[i].Number); } } FetchUpdates(); return(true); } return(false); }
private bool SortMovingTrams(TramLocation location) { var movingTrams = _repo.GetAllTramsWithLocation(location); if (movingTrams.Count != 0) { UpdateTracks(); var sorter = new TramSortingAlgoritm(_allTracks, _repo); for (var i = 0; i < movingTrams.Count; i++) { var beheerTram = BeheerTram.ToBeheerTram(movingTrams[i]); if (location == TramLocation.ComingIn) { if (beheerTram.DepartureTime == null) { beheerTram.EditTramDepartureTime(GetExitTime(beheerTram)); } sorter.AssignTramLocation(beheerTram); } else if (location == TramLocation.GoingOut) { beheerTram.EditTramLocation(TramLocation.Out); movingTrams[i] = beheerTram; _repo.EditTram(movingTrams[i]); _repo.WipeSectorByTramId(movingTrams[i].Number); Console.WriteLine($"Tram {beheerTram.Number} left the remise."); } } return(true); } return(false); }
public void FetchUpdates() { AllTracks = new List <BeheerTrack>(); foreach (Track track in repo.GetTracksAndSectors()) { AllTracks.Add(track == null ? null : BeheerTrack.ToBeheerTrack(track)); } AllTrams = new List <BeheerTram>(); foreach (Tram tram in repo.GetAllTrams()) { AllTrams.Add(tram == null ? null : BeheerTram.ToBeheerTram(tram)); } }
public void EditTram() { var tram = _logisticRepository.GetTram(1); Assert.IsNotNull(tram); var newTram = BeheerTram.ToBeheerTram(tram); newTram.EditTramStatus(TramStatus.Cleaning); newTram.EditTramDepartureTime(new DateTime(2017, 6, 15, 08, 0, 0, DateTimeKind.Unspecified)); newTram.EditTramLocation(TramLocation.Out); _logisticRepository.EditTram(newTram); var fetchTram = _logisticRepository.GetTram(1); Assert.IsNotNull(fetchTram); Assert.AreEqual(JsonConvert.SerializeObject(newTram), JsonConvert.SerializeObject(fetchTram)); }