Exemple #1
0
        public string Unlock(string tracks, string sectors)
        {
            int[] unlockSectors = { -1 };
            int[] unlockTracks;

            try
            {
                if (!string.IsNullOrEmpty(sectors))
                {
                    unlockSectors = Parse(sectors);
                    for (var i = 0; i < unlockSectors.Length; i++)
                    {
                        unlockSectors[i] -= 1;
                    }
                }
                unlockTracks = Parse(tracks);
            }
            catch
            {
                return("De input is incorrect.");
            }

            foreach (var track in AllTracks)
            {
                if (Array.IndexOf(unlockTracks, track.Key) <= -1)
                {
                    continue;
                }
                var beheerTrack = BeheerTrack.ToBeheerTrack(track.Value);
                beheerTrack.UnlockTrack();
                _repo.EditTrack(beheerTrack);
            }

            foreach (var track in AllTracks)
            {
                if (Array.IndexOf(unlockTracks, track.Key) <= -1)
                {
                    continue;
                }
                for (var i = 0; i < track.Value.Sectors.Count - 1; i++)
                {
                    if (Array.IndexOf(unlockSectors, i) <= -1)
                    {
                        continue;
                    }
                    var beheerSector =
                        track.Value.Sectors[i] == null ? null : BeheerSector.ToBeheerSector(track.Value.Sectors[i]);
                    if (beheerSector == null)
                    {
                        continue;
                    }
                    beheerSector.UnLock();
                    _repo.EditSector(beheerSector);
                }
            }
            Update();
            return(null);
        }
Exemple #2
0
 private void Update()
 {
     AllTracks = new Dictionary <int, BeheerTrack>();
     foreach (var track in _repo.GetTracksAndSectors())
     {
         if (track == null)
         {
             continue;
         }
         AllTracks.Add(track.Number, BeheerTrack.ToBeheerTrack(track));
     }
     AllTrams = new Dictionary <int, BeheerTram>();
     foreach (var tram in _repo.GetAllTrams())
     {
         if (tram == null)
         {
             continue;
         }
         AllTrams.Add(tram.Number, BeheerTram.ToBeheerTram(tram));
     }
 }
Exemple #3
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);
        }