public static FishingRecordRepository GetInstance() { if (_instance == null) { _instance = new FishingRecordRepository(); } return(_instance); }
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()); }
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()); }
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()); }
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(); } }