private List <AdminEditProductClassAttributeViewModel> GetProductClassAttribute(ProductClass productClass = null) { var lst = new List <AdminEditProductClassAttributeViewModel>(); var attr = _productSevice.GetAllAttribute(); List <ProductClassAttribute> listcheck = null; if (productClass != null) { listcheck = _productSevice.GetListProductClassAttributeForProductClassId(productClass.Id); } foreach (var it in attr) { var a = new AdminEditProductClassAttributeViewModel { Id = it.Id, Name = it.LangName, }; if (productClass != null) { foreach (var item in listcheck) { if (it.Id == item.ProductAttributeId) { a.IsCheck = true; a.IsShow = item.IsShow; break; } } } lst.Add(a); } return(lst); }