public DTO.Product CreateProduct(DataAccess.Product product, bool includeOnlyActive = true) { CheckHelper.ArgumentNotNull(product, "product"); CheckHelper.ArgumentWithinCondition(!product.IsNew(), "!product.IsNew()"); return (_dtoCache.Get( product, p => { var httpService = Container.Get <IHttpService>(); var result = new DTO.Product { Id = p.Id, Name = p.Name, Description = p.Description, PreviewPictureURL = httpService.GetAbsoluteURLFromRelativeURL(p.PreviewPictureURL), FullPictureURL = httpService.GetAbsoluteURLFromRelativeURL(p.FullPictureURL), VendorShopURL = p.VendorShopURL, Active = p.Active }; CopyTrackableFields(result, p); return result; }, (pDto, p) => { pDto.Brand = CreateBrand(p.Brand, includeOnlyActive); pDto.SubCategory = CreateSubCategory(p.SubCategory, includeOnlyActive); pDto.ProductSizes = p.ProductSizes .Where(ps => ps.Active || !includeOnlyActive) .OrderBy(ps => ps.Size.Name) .Select(ps => CreateProductSize(ps, includeOnlyActive)) .ToArray(); })); }