Beispiel #1
0
        public void PostStock(string productIdentifier, Stock stock)
        {
            ProductIdentifier productIdentifierObj = new ProductIdentifier(productIdentifier);

            IContent content = ApplicationContext.Current.Services.ContentService.GetById(productIdentifierObj.NodeId);
            IProductInformationExtractor <IContent, VariantPublishedContent> productInformationExtractor = ContentProductInformationExtractor.Instance;
            IVariantService <IContent, VariantPublishedContent> contentVariantService = ContentVariantService.Instance;

            long storeId = productInformationExtractor.GetStoreId(content);
            VariantPublishedContent variant = contentVariantService.GetVariant(storeId, content, productIdentifierObj.VariantId);

            stock.Sku = !string.IsNullOrEmpty(stock.Sku) ? stock.Sku : productInformationExtractor.GetSku(content, variant);

            ProductService.Instance.SetStock(storeId, stock.Sku, !string.IsNullOrEmpty(stock.Value) ? stock.Value.ParseToDecimal() : null);
        }
        public HttpResponseMessage Get(string pageId, long vatGroupId)
        {
            ProductIdentifier productIdentifierObj = new ProductIdentifier(pageId);
            IContent          content = ApplicationContext.Current.Services.ContentService.GetById(productIdentifierObj.NodeId);
            IProductInformationExtractor <IContent, VariantPublishedContent> productInformationExtractor = ContentProductInformationExtractor.Instance;

            long storeId = productInformationExtractor.GetStoreId(content);

            HttpResponseMessage response = new HttpResponseMessage {
                Content = new StringContent(VatGroupService.Instance.Get(storeId, vatGroupId).ToJson())
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            return(response);
        }
Beispiel #3
0
        public Stock GetStock(string productIdentifier)
        {
            Stock             stock = new Stock();
            ProductIdentifier productIdentifierObj = new ProductIdentifier(productIdentifier);

            IContent content = ApplicationContext.Current.Services.ContentService.GetById(productIdentifierObj.NodeId);
            IProductInformationExtractor <IContent, VariantPublishedContent> productInformationExtractor = ContentProductInformationExtractor.Instance;
            IVariantService <IContent, VariantPublishedContent> contentVariantService = ContentVariantService.Instance;

            long storeId = productInformationExtractor.GetStoreId(content);
            VariantPublishedContent variant = contentVariantService.GetVariant(storeId, content, productIdentifierObj.VariantId);

            stock.Sku = productInformationExtractor.GetSku(content, variant);
            decimal?stockValue = ProductService.Instance.GetStock(storeId, stock.Sku);

            stock.Value = stockValue != null?stockValue.Value.ToString("0.####") : "";

            return(stock);
        }