public List <AttributeCategoryDTO> GetGroupCategories() { List <AttributeCategoryDTO> cats = _attributeService.GetAttributeCategory(_attributeTypeGroupCategory); foreach (AttributeCategoryDTO cat in cats) { if (cat.RequiresActiveAttribute) { cat.Attribute = _attributeService.GetOneAttributeByCategoryId(cat.CategoryId); } } //do not return any categories where it requires an active attribute but there are no active attributes cats.RemoveAll(cat => cat.RequiresActiveAttribute && cat.Attribute == null); return(cats); }