Ejemplo n.º 1
0
        protected override IProduct PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
                      .Where(GetBaseWhereClause(), new { Key = key });

            var dto = Database.Fetch <ProductDto, ProductVariantDto, ProductVariantIndexDto>(sql).FirstOrDefault();

            if (dto == null)
            {
                return(null);
            }

            var inventoryCollection        = ((ProductVariantRepository)_productVariantRepository).GetCategoryInventoryCollection(dto.ProductVariantDto.Key);
            var productAttributeCollection = ((ProductVariantRepository)_productVariantRepository).GetProductAttributeCollection(dto.ProductVariantDto.Key);

            var factory = new ProductFactory(productAttributeCollection, inventoryCollection, GetProductOptionCollection(dto.Key), GetProductVariantCollection(dto.Key));
            var product = factory.BuildEntity(dto);

            // TODO - inventory
            //((ProductVariant) ((Product) product).MasterVariant).CatalogInventoryInventory =
            //    ((ProductVariantRepository) _productVariantRepository).GetCategoryInventoryCollection(
            //        ((Product) product).ProductVariantKey);

            //// Build the list of options
            //product.ProductOptions = GetProductOptionCollection(product.Key);

            //// Build the list of product variants
            //product.ProductVariants = GetProductVariantCollection(product.Key);

            product.ResetDirtyProperties();

            return(product);
        }