Ejemplo n.º 1
0
        public static FishingRecordRepository GetInstance()
        {
            if (_instance == null)
            {
                _instance = new FishingRecordRepository();
            }

            return(_instance);
        }
Ejemplo n.º 2
0
        public static int[] GetMonths()
        {
            HashSet <int> months = new HashSet <int>();;

            foreach (FishingRecord record in FishingRecordRepository.GetInstance().GetRecords())
            {
                months.Add(record.DateTimeInterval.Start.Month);
                months.Add(record.DateTimeInterval.End.Month);
            }

            return(months.ToArray());
        }
Ejemplo n.º 3
0
        public static int[] GetYears()
        {
            HashSet <int> years = new HashSet <int>();

            foreach (FishingRecord record in FishingRecordRepository.GetInstance().GetRecords())
            {
                years.Add(record.DateTimeInterval.Start.Year);
                years.Add(record.DateTimeInterval.End.Year);
            }

            return(years.ToArray());
        }
Ejemplo n.º 4
0
        public static string[] GetFishNames()
        {
            HashSet <string> fishNames = new HashSet <string>();;

            foreach (FishingRecord record in FishingRecordRepository.GetInstance().GetRecords())
            {
                foreach (string fishName in record.FishCatch.GetCaughtFish())
                {
                    fishNames.Add(fishName);
                }
            }

            return(fishNames.ToArray());
        }
Ejemplo n.º 5
0
        public void DeleteLocation(int index)
        {
            if (0 <= index & index < _locations.Count)
            {
                Location location = _locations[index];
                foreach (FishingRecord record in FishingRecordRepository.GetInstance().GetRecords())
                {
                    if (location == record.Location)
                    {
                        throw new LocationPartOfFishingRecordException();
                    }
                }

                _locations.RemoveAt(index);

                NotifyObservers(location);
            }
            else
            {
                throw new LocationDoesntExistException();
            }
        }