private FilterCatalogModel _filterCatalog(CatalogModel model) { var store = new StoreAction(); var filterModel = new FilterCatalogModel(); filterModel.groupId = model.groupId; if (model.goods == null || model.goods.Count == 0) { return(filterModel); } filterModel.minPrice = filterModel.selectedMinPrice = model.goods.Min(s => s.price); filterModel.maxPrice = filterModel.selectedMaxPrice = model.goods.Max(s => s.price); var brands = model.goods.Select(s => s.brandId).Where(s => s.HasValue).Distinct().ToList(); filterModel.brands = new List <BrandFilter>(); var brandsAll = store.GetGoodBrands(); if (brands?.Count() > 0) { foreach (var item in brands) { var brand = brandsAll.Single(s => s.id == item); filterModel.brands.Add(new BrandFilter { brandId = brand.id, brandName = brand.name, brandCount = model.goods.Count(s => s.brandId == brand.id), isChecked = true }); } } return(filterModel); }