private PagedCollection<IndexProduct> GetProducts(int pageindex, int pagesize, ImageSize imgSize, PrdType prdType) { var pagedProducts = _adminService.GetProductsByType(pageindex, pagesize, prdType); List<IndexProduct> indexProducts = new List<IndexProduct>(); foreach (var item in pagedProducts.Items) { var imgs = _imgService.GetImages(item._id); var selectImg = imgs.FirstOrDefault(m => m.Width == imgSize.Width && m.Height == imgSize.Height); if (selectImg == null) continue; IndexProduct idxProduct = new IndexProduct(); idxProduct.Product = item; idxProduct.Image = selectImg; indexProducts.Add(idxProduct); } return new PagedCollection<IndexProduct>(indexProducts, pagedProducts.PageIndex, pagedProducts.PageSize, pagedProducts.ItemCount); }
public PagedCollection<IndexProduct> GetBriefsProducts(int pageindex, int pagesize, ImageSize imgSize) { return GetProducts(pageindex, pagesize, imgSize, PrdType.Briefs); }