Exemplo n.º 1
0
        public IActionResult Index(int id)
        {
            CatalogContent catalogContent = new CatalogContent
            {
                Catalogs = _directorySystemFacade.GetSubcatalogs(id).Select(
                    x => new CatalogDto
                {
                    Id   = x.Id,
                    Name = x.Name,
                    OrderInParentCatalog = x.OrderInParentCatalog,
                    ParentCatalogId      = x.ParentCatalogId
                }).ToList(),
                TextBlocks = _directorySystemFacade.GetCatalogAttachments(id).Select(
                    x => new TextBlockDto
                {
                    Id   = x.Id,
                    Name = x.Name,
                    OrderInParentCatalog = x.OrderInParentCatalog,
                    ParentCatalogId      = x.ParentCatalogId,
                    Text = x.Text
                }).ToList()
            };

            return(View(catalogContent));
        }
Exemplo n.º 2
0
        protected void ImportNodes(CatalogRoot root, CatalogContent catalogContent)
        {
            NodeImporter nodeImporter = ServiceLocator.Current.GetInstance<NodeImporter>();

            var defaultContentType = _typeRepository.Load(root.defaults.defaultNodeType);
            nodeImporter.DefaultContentType = defaultContentType;
            _log.Debug("Default content type: {0}", defaultContentType != null ? defaultContentType.FullName : "None");

            nodeImporter.RootCatalog = catalogContent;
            nodeImporter.Defaults = root.defaults;

            nodeImporter.Import(root.nodes);
        }
Exemplo n.º 3
0
        protected void ImportEntries(CatalogRoot root, CatalogContent catalogContent)
        {
            EntryImporter entryImporter = ServiceLocator.Current.GetInstance <EntryImporter>();

            var defaultContentType = _typeRepository.Load(root.defaults.defaultEntryType);

            entryImporter.DefaultContentType = defaultContentType;
            _log.Debug("Default content type: {0}", defaultContentType != null ? defaultContentType.FullName : "None");

            entryImporter.RootCatalog = catalogContent;
            entryImporter.Defaults    = root.defaults;

            entryImporter.Import(root.entries);
        }
Exemplo n.º 4
0
        public async Task <Catalog> CreateCatalog(string name)
        {
            CatalogContent content = new CatalogContent();

            content.ExternalIdentifier = null;
            content.Menu = null;
            content.OEMs = null;
            content.PlatformIdentifier = _platformIdentifier;
            content.Name = name;

            Catalog newEntity = new Catalog
            {
                Contents = content
            };

            var entity = await _context.Catalogs.AddAsync(newEntity);

            return(entity);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            catalogContent = new CatalogContent();
            CatalogItem catalogItem = new CatalogItem {
                Name    = "Orange", Price = 80, Quantity = 50,
                Vendors = new List <Vendor> {
                    new Vendor {
                        Id = 1, Name = "ABC"
                    },
                    new Vendor {
                        Id = 2, Name = "XYZ"
                    },
                    new Vendor {
                        Id = 3, Name = "DEF"
                    },
                }
            };

            InsertItem(catalogItem);
            GetCatalogItems();
            Console.ReadLine();
        }
Exemplo n.º 6
0
        private ProductSearchResults GetSearchResults(IContent currentContent,
                                                      CommerceFilterOptionViewModel filterOptions,
                                                      string selectedfacets,
                                                      IEnumerable <Filter> filters = null,
                                                      int catalogId = 0)
        {
            //If contact belong organization, only find product that belong the categories that has owner is this organization
            var            contact             = PrincipalInfo.CurrentPrincipal.GetCustomerContact();
            var            organizationId      = contact?.ContactOrganization?.PrimaryKeyId ?? Guid.Empty;
            CatalogContent catalogOrganization = null;

            if (organizationId != Guid.Empty)
            {
                //get category that has owner id = organizationId
                catalogOrganization = _contentRepository
                                      .GetChildren <CatalogContent>(_referenceConverter.GetRootLink())
                                      .FirstOrDefault(x => !string.IsNullOrEmpty(x.Owner) && x.Owner.Equals(organizationId.ToString(), StringComparison.OrdinalIgnoreCase));
            }

            var pageSize = filterOptions.PageSize > 0 ? filterOptions.PageSize : DefaultPageSize;
            var market   = _currentMarket.GetCurrentMarket();

            var query = _findClient.Search <EntryContentBase>();

            query = ApplyTermFilter(query, filterOptions.Q, filterOptions.TrackData);
            query = query.Filter(x => x.Language.Name.Match(_languageResolver.GetPreferredCulture().Name));

            if (organizationId != Guid.Empty && catalogOrganization != null)
            {
                query = query.Filter(x => x.Outline().PrefixCaseInsensitive(catalogOrganization.Name));
            }

            var nodeContent = currentContent as NodeContent;

            if (nodeContent != null)
            {
                var outline = GetOutline(nodeContent.Code);
                query = query.FilterOutline(new[] { outline });
            }

            query = query.FilterMarket(market);
            var facetQuery = query;

            query = FilterSelected(query, filterOptions.FacetGroups);
            query = ApplyFilters(query, filters);
            query = OrderBy(query, filterOptions);
            //Exclude products from search
            //query = query.Filter(x => (x as ProductContent).ExcludeFromSearch.Match(false));

            if (catalogId != 0)
            {
                query = query.Filter(x => x.CatalogId.Match(catalogId));
            }

            query = query.ApplyBestBets()
                    .Skip((filterOptions.Page - 1) * pageSize)
                    .Take(pageSize)
                    .StaticallyCacheFor(TimeSpan.FromMinutes(1));

            var result = query.GetContentResult();

            return(new ProductSearchResults
            {
                ProductViewModels = CreateProductViewModels(result, currentContent, filterOptions.Q),
                FacetGroups = GetFacetResults(filterOptions.FacetGroups, facetQuery, selectedfacets),
                TotalCount = result.TotalMatching,
                DidYouMeans = string.IsNullOrEmpty(filterOptions.Q) ? null : _findClient.Statistics().GetDidYouMean(filterOptions.Q),
                Query = filterOptions.Q,
            });
        }