public void AddFavoritCategory(RankingCategory category) { var allPrio = new[] { HighPriorityCategory, MiddlePriorityCategory, LowPriorityCategory }; foreach (var prio in allPrio) { var target = prio.FirstOrDefault(x => x.Category == category); if (target != null) { prio.Remove(target); } } HighPriorityCategory.Add(new RankingCategoryInfo(category)); }
public bool AddFavoritCategory(RankingCategory category) { var target = MiddlePriorityCategory.FirstOrDefault(x => x.Category == category); if (target != null) { MiddlePriorityCategory.Remove(target); HighPriorityCategory.Add(target); return(true); } else if ((target = LowPriorityCategory.FirstOrDefault(x => x.Category == category)) != null) { LowPriorityCategory.Remove(target); HighPriorityCategory.Add(target); return(true); } return(false); }