public void LoadYears() { SelectedYear = 0; foreach (int year in Years.Where(y => y != 0).ToList()) { Years.Remove(year); } if (!Years.Contains(0)) { Years.Add(0); } foreach (int year in YearModel.List()) { Years.Add(year); } SelectedYear = YearModel.GetCurrentYear(); }
public void LoadYears(IEnumerable <int> years) { SelectedYear = 0; foreach (int year in Years.Where(y => y != 0).ToList()) { Years.Remove(year); } if (!Years.Contains(0)) { Years.Add(0); } foreach (int year in years) { Years.Add(year); } SelectedYear = YearModel.GetCurrentYear(); if (SelectedYear == 0 || !Years.Contains(SelectedYear)) { SelectedYear = Years.LastOrDefault(); } }