Exemplo n.º 1
0
        private static CatalogItem ProductToCatalogItem(IEnumerable<Promotion> promotions, Customer customer, Product relatedProduct)
        {
            var catalogItem = new CatalogItem
            {
                Id = relatedProduct.Id,
                Name = relatedProduct.Name,
                Description = relatedProduct.Description,
                Title1 = relatedProduct.Title1,
                Title2 = relatedProduct.Title2,
                TitlesCount = relatedProduct.TitlesCount,
                OriginalPrice = relatedProduct.Price,
                PlayCount = relatedProduct.PlayCount
            };

            var promotion = promotions != null && customer != null ? promotions.FirstOrDefault(p => p.CustomerId == customer.Id && p.ProductId == relatedProduct.Id) : null;
            if (promotion != null)
            {
                catalogItem.CurrentPrice = promotion.NewPrice;
                catalogItem.PromotionDiscount = promotion.PromotionDiscount;
            }
            return catalogItem;
        }
 public CatalogItemDetailsModel(CatalogItem item, IEnumerable<CatalogItem> relatedItems)
 {
     _item = item;
     _relatedItems = relatedItems;
 }