Example #1
0
        public int[] SearchProducts(string slug, string version, string query)
        {
            var definition = _contentDefinitionService.GetServiceDefinition(slug, version);
            var condition  = new ProductQuery {
                Definition = definition.Content, Query = query, ExstensionContentIds = definition.ExstensionContentIds
            };
            var products = _articleMatchService.MatchArticles(definition.Content.ContentId, condition, MatchMode.Strict);

            return(products.Select(product => product.Id).ToArray());
        }
        public async Task <Article> Read(Stream stream)
        {
            using (var reader = new StreamReader(stream))
            {
                string line = await reader.ReadToEndAsync();

                Content definition = null;
                object  slug       = null;
                object  version    = null;

                _actionContext?.RouteData?.Values?.TryGetValue("slug", out slug);
                _actionContext?.RouteData?.Values?.TryGetValue("version", out version);

                if (slug == null && version == null)
                {
                    var type      = GetTypeName(line);
                    var contentId = _productContentResolver.GetContentIdByType(type);
                    definition = _contentDefinitionService.GetDefinitionForContent(0, contentId);
                }
                else
                {
                    definition = _contentDefinitionService.GetServiceDefinition((string)slug, (string)version).Content;
                }

                return(_jsonProductService.DeserializeProduct(line, definition));
            }
        }
Example #3
0
        public Article ReadProduct(Stream stream)
        {
            _actionContext.RouteData.Values.TryGetValue("slug", out object slug);
            _actionContext.RouteData.Values.TryGetValue("version", out object version);

            var     productXml = XDocument.Load(stream);
            Content definition = null;

            if (slug == null && version == null)
            {
                var type      = GetTypeName(productXml);
                var contentId = _productContentResolver.GetContentIdByType(type);
                definition = _contentDefinitionService.GetDefinitionForContent(0, contentId);
            }
            else
            {
                definition = _contentDefinitionService.GetServiceDefinition((string)slug, (string)version).Content;
            }

            return(ReadProduct(productXml, definition));
        }
Example #4
0
        public Dictionary <string, object>[] GetProductsList(string slug, string version, bool isLive = false, long startRow = 0, long pageSize = int.MaxValue)
        {
            var definition = _contentDefinitionService.GetServiceDefinition(slug, version);

            return(_productService.GetProductsList(definition, startRow, pageSize, isLive));
        }