public List<ManufacturerOverviewModel> PrepareManufacturersOverviewModel( ICollection<ProductManufacturer> manufacturers, IDictionary<int, ManufacturerOverviewModel> cachedModels = null, bool forProductDetailPage = false) { var model = new List<ManufacturerOverviewModel>(); if (cachedModels == null) { cachedModels = new Dictionary<int, ManufacturerOverviewModel>(); } foreach (var pm in manufacturers) { var manufacturer = pm.Manufacturer; ManufacturerOverviewModel item; if (!cachedModels.TryGetValue(manufacturer.Id, out item)) { item = new ManufacturerOverviewModel { Id = manufacturer.Id, Name = manufacturer.Name, Description = manufacturer.Description, SeName = manufacturer.GetSeName() }; if (_catalogSettings.ShowManufacturerPicturesInProductDetail) { item.PictureModel = PrepareManufacturerPictureModel(manufacturer, manufacturer.GetLocalized(x => x.Name)); } cachedModels.Add(item.Id, item); } model.Add(item); } return model; }
public List<ManufacturerOverviewModel> PrepareManufacturersOverviewModel( ICollection<ProductManufacturer> manufacturers, IDictionary<int, ManufacturerOverviewModel> cachedModels = null) { var model = new List<ManufacturerOverviewModel>(); if (cachedModels == null) { cachedModels = new Dictionary<int, ManufacturerOverviewModel>(); } foreach (var pm in manufacturers) { var manufacturer = pm.Manufacturer; ManufacturerOverviewModel item; if (!cachedModels.TryGetValue(manufacturer.Id, out item)) { item = new ManufacturerOverviewModel { Id = manufacturer.Id, Name = manufacturer.Name, Description = manufacturer.Description, SeName = manufacturer.GetSeName() }; Picture pic = manufacturer.Picture; if (pic != null) { item.PictureModel = new PictureModel { PictureId = pic.Id, Title = T("Media.Product.ImageLinkTitleFormat", manufacturer.Name), AlternateText = T("Media.Product.ImageAlternateTextFormat", manufacturer.Name), ImageUrl = _pictureService.GetPictureUrl(pic), }; } cachedModels.Add(item.Id, item); } model.Add(item); } return model; }
public List<ManufacturerOverviewModel> PrepareManufacturersOverviewModel(ICollection<ProductManufacturer> manufacturers) { var model = new List<ManufacturerOverviewModel>(); foreach (var pm in manufacturers) { var manufacturer = pm.Manufacturer; var item = new ManufacturerOverviewModel { Id = manufacturer.Id, Name = manufacturer.Name, Description = manufacturer.Description, SeName = manufacturer.GetSeName() }; Picture pic = manufacturer.Picture; if (pic != null) { item.PictureModel = new PictureModel { PictureId = pic.Id, Title = T("Media.Product.ImageLinkTitleFormat", manufacturer.Name), AlternateText = T("Media.Product.ImageAlternateTextFormat", manufacturer.Name), ImageUrl = _pictureService.GetPictureUrl(pic), }; } model.Add(item); } return model; }
protected List<ManufacturerOverviewModel> PrepareManufacturersOverviewModel(ICollection<ProductManufacturer> manufacturers) { //var manufacturers = _manufacturerService.GetProductManufacturersByProductId(productId); var model = new List<ManufacturerOverviewModel>(); foreach (var manufacturer in manufacturers) { var item = new ManufacturerOverviewModel { Id = manufacturer.Manufacturer.Id, Name = manufacturer.Manufacturer.Name, Description = manufacturer.Manufacturer.Description, SeName = manufacturer.Manufacturer.GetSeName() }; var pic = _pictureService.GetPictureById(manufacturer.Manufacturer.PictureId.GetValueOrDefault()); if (pic != null) { item.PictureModel = new PictureModel() { PictureId = pic.Id, // codehint: sm-add Title = T("Media.Product.ImageLinkTitleFormat", manufacturer.Manufacturer.Name), AlternateText = T("Media.Product.ImageAlternateTextFormat", manufacturer.Manufacturer.Name), ImageUrl = _pictureService.GetPictureUrl(manufacturer.Manufacturer.PictureId.GetValueOrDefault()), }; } model.Add(item); } return model; }