Beispiel #1
0
        public async Task OnGetAsync(int?eventid)
        {
            Track = await _context.Tracks
                    .Where(e => e.SetTracks.Any(r => r.EventSet.EventId == eventid))
                    .ToListAsync();

            AllTracks = await _context.Tracks.ToListAsync();

            if (string.IsNullOrEmpty(SearchString))
            {
                return;
            }

            var searchStrings = SearchString.ToLower().Split(' ');

            foreach (var searchString in searchStrings)
            {
                if (searchString[0] != '!')
                {
                    AllTracks = AllTracks.Where(e => e.TrackName.ToLower().Contains((searchString))).ToList();
                }
                else
                {
                    AllTracks = AllTracks.Where(e => !e.TrackName
                                                .ToLower()
                                                .Contains((searchString.Substring(1))))
                                .ToList();
                }
            }
        }
Beispiel #2
0
        internal static List <Track> GetStorageTracks(StationController station)
        {
            var trackNames = StorageTrackNames[station.stationInfo.YardID];

            return(AllTracks
                   .Where(t => trackNames.Contains(t.ID.ToString()))
                   .ToList());
        }
Beispiel #3
0
        internal static List <Track> GetLoadingTracks(StationController station)
        {
            var trackNames = PlatformTrackNames[station.stationInfo.YardID];

            var result = AllTracks.Where(t => trackNames.Contains(t.ID.ToString())).ToList();

            return(result);
        }
Beispiel #4
0
        public bool DeleteSector(string _track)
        {
            int trackNumber = ToInt(_track);

            foreach (Track track in AllTracks.Where(x => x.Number == trackNumber && x.Sectors[x.Sectors.Count - 1].OccupyingTram == null))
            {
                track.DeleteSector();
                repo.DeleteSectorFromTrack(track, track.Sectors[track.Sectors.Count - 1]);
                Update();
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        public bool AddSector(string _track)
        {
            int trackNumber = ToInt(_track);

            foreach (Track track in AllTracks.Where(x => x.Number == trackNumber))
            {
                track.AddSector(new Sector(track.Sectors.Count + 1));
                repo.AddSector(track.Sectors[track.Sectors.Count - 1], track);
                Update();
                return(true);
            }
            return(false);
        }
Beispiel #6
0
        public bool DeleteTrack(string _track)
        {
            int trackNumber = ToInt(_track);

            foreach (Track track in AllTracks.Where(x => x.Number == trackNumber))
            {
                if (track.Sectors.Where(x => x.OccupyingTram != null).Count() > 0)
                {
                    return(false);
                }
                repo.DeleteTrack(track);
                Update();
                return(true);
            }
            return(false);
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AllTracks = await _context.Tracks.ToListAsync();

            EventSet = await _context.EventSets
                       .Include(e => e.Dj)
                       .Include(e => e.Event)
                       .Include(e => e.SetTracks)
                       .ThenInclude(e => e.Track)
                       .FirstOrDefaultAsync(m => m.EventSetId == id);

            if (string.IsNullOrEmpty(SearchString))
            {
                return(Page());
            }

            var searchStrings = SearchString.ToLower().Split(' ');

            foreach (var searchString in searchStrings)
            {
                if (searchString[0] != '!')
                {
                    AllTracks = AllTracks.Where(e => e.TrackName.ToLower().Contains((searchString))).ToList();
                }
                else
                {
                    AllTracks = AllTracks.Where(e => !e.TrackName
                                                .ToLower()
                                                .Contains((searchString.Substring(1))))
                                .ToList();
                }
            }

            if (EventSet == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #8
0
        internal static List <Track> GetLoadingTracks(StationController station)
        {
            var trackNames = PlatformTrackNames[station.stationInfo.YardID];

            var result = AllTracks.Where(t => trackNames.Contains(t.ID.ToString())).ToList();

            // fix track IDs at Food Factory
            foreach (var track in result)
            {
                if (track.ID.FullDisplayID == "#Y-#S-168-#T")  // used to be #Y-#S-354-#T
                {
                    track.OverrideTrackID(new TrackID("FF", "B", "1", TrackID.LOADING_PASSENGER_TYPE));
                }
                else if (track.ID.FullDisplayID == "#Y-#S-491-#T")  // used to be #Y-#S-339-#T
                {
                    track.OverrideTrackID(new TrackID("FF", "B", "2", TrackID.LOADING_PASSENGER_TYPE));
                }
            }

            return(result);
        }
Beispiel #9
0
        public bool MoveTram(string _tram, string _track, string _sector)
        {
            int moveTram   = ToInt(_tram);
            int moveTrack  = ToInt(_track);
            int moveSector = ToInt(_sector) - 1;

            foreach (Track track in AllTracks.Where(x => x.Number == moveTrack && x.Sectors.Count > moveSector))
            {
                foreach (Tram tram in AllTrams.Where(x => x.Number == moveTram))
                {
                    BeheerSector beheerSector = track.Sectors[moveSector] == null ? null : BeheerSector.ToBeheerSector(track.Sectors[moveSector]);
                    if (beheerSector.SetOccupyingTram(tram))
                    {
                        repo.WipeSectorByTramId(tram.Number);
                        repo.EditSector(beheerSector);
                        Update();
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #10
0
        public string Lock(string tracks, string sectors)
        {
            int[] lockSectors = { -1 };
            int[] lockTracks;

            try
            {
                if (!string.IsNullOrEmpty(sectors))
                {
                    lockSectors = Parse(sectors);
                    for (var i = 0; i < lockSectors.Length; i++)
                    {
                        lockSectors[i] -= 1;
                    }
                }

                lockTracks = Parse(tracks);
            }
            catch
            {
                return("De input klopt niet.");
            }
            if (lockTracks[0] == -1)
            {
                return(null);
            }

            var newLockTracks = AllTracks.Where(x => lockTracks.Contains(x.Key));

            foreach (var track in newLockTracks)
            {
                var beheerTrack = BeheerTrack.ToBeheerTrack(track.Value);
                beheerTrack.LockTrack();
                _repo.EditTrack(beheerTrack);
            }


            foreach (var track in AllTracks)
            {
                if (Array.IndexOf(lockTracks, track.Key) <= -1)
                {
                    continue;
                }
                for (var i = 0; i < track.Value.Sectors.Count - 1; i++)
                {
                    if (Array.IndexOf(lockSectors, i) <= -1)
                    {
                        continue;
                    }
                    var beheerSector = track.Value.Sectors[i] == null
                        ? null
                        : BeheerSector.ToBeheerSector(track.Value.Sectors[i]);
                    if (beheerSector == null)
                    {
                        continue;
                    }
                    beheerSector.Lock();
                    _repo.EditSector(beheerSector);
                }
            }

            Update();
            return(null);
        }