コード例 #1
0
 public ProductType(
     VariantService variantService,
     CategoryService categoryService,
     CurrencyService currencyService,
     ChannelService channelService,
     CountryService countryService,
     Web.Models.Products.ProductPriceModelBuilder productPriceModelBuilder,
     BaseProductService baseProductService,
     UrlService urlService)
 {
     Name        = "Product";
     Description = "A product";
     Field(p => p.SystemId, type: typeof(IdGraphType)).Description("The system Id");
     Field(p => p.Id).Description("The article number");
     Field(p => p.Name);
     Field(p => p.Images);
     Field(p => p.Brand, nullable: true);
     Field(p => p.Color);
     Field(p => p.Description);
     Field(p => p.IsInStock);
     Field(p => p.FormattedPrice);
     Field(p => p.ShowBuyButton);
     Field(p => p.ShowQuantityField);
     Field(p => p.Size);
     Field(p => p.StockStatusDescription);
     Field(p => p.Slug);
     Field(p => p.UseVariantUrl);
 }
コード例 #2
0
 public ProductCatalogStructurePackage(BaseProductService baseProductService, ProductListService productListService,
                                       RelationshipTypeService relationshipTypeService, CategoryService categoryService,
                                       UnitOfMeasurementService unitOfMeasurementService, DataService dataService,
                                       FieldTemplateService fieldTemplateService,
                                       LanguageService languageService, VariantService variantService,
                                       InventoryService inventoryService,
                                       PriceListService priceListService,
                                       StructureInfoService structureInfoService,
                                       CurrencyService currencyService,
                                       FilterService filterService,
                                       InventoryItemService inventoryItemService,
                                       PriceListItemService priceListItemService,
                                       ProductListItemService productListItemService)
 {
     _baseProductService        = baseProductService;
     _categoryService           = categoryService;
     _dataService               = dataService;
     _fieldTemplateService      = fieldTemplateService;
     _languageService           = languageService;
     _variantService            = variantService;
     _inventoryService          = inventoryService;
     _priceListService          = priceListService;
     _structureInfoService      = structureInfoService;
     _currencyService           = currencyService;
     _filterService             = filterService;
     _productListService        = productListService;
     _relationshipTypeService   = relationshipTypeService;
     _unitOfMeasurementService  = unitOfMeasurementService;
     _bidirectionalRelationList = new List <ImportBidirectionalRelation>();
     _inventoryItemService      = inventoryItemService;
     _priceListItemService      = priceListItemService;
     _productListItemService    = productListItemService;
 }
コード例 #3
0
 public ProductDemoService(BaseProductService baseProductService, FieldTemplateService fieldTemplateService, VariantService variantService, CategoryService categoryService)
 {
     _baseProductService   = baseProductService;
     _fieldTemplateService = fieldTemplateService;
     _variantService       = variantService;
     _categoryService      = categoryService;
 }
コード例 #4
0
 public ProductController(
     ProductPageViewModelBuilder productPageViewModelBuilder,
     BaseProductService baseProductService,
     IEnumerable <IRenderingValidator <BaseProduct> > renderingValidators)
 {
     _productPageViewModelBuilder = productPageViewModelBuilder;
     _baseProductService          = baseProductService;
     _renderingValidators         = renderingValidators;
 }
コード例 #5
0
 public CartViewModelBuilder(CartService cartService, RequestModelAccessor requestModelAccessor, UrlService urlService,
                             VariantService variantService, BaseProductService baseProductService, ModuleECommerce moduleECommerce,
                             UnitOfMeasurementService unitOfMeasurementService)
 {
     _cartService              = cartService;
     _requestModelAccessor     = requestModelAccessor;
     _urlService               = urlService;
     _variantService           = variantService;
     _baseProductService       = baseProductService;
     _moduleECommerce          = moduleECommerce;
     _unitOfMeasurementService = unitOfMeasurementService;
 }
コード例 #6
0
 public ProductBlockViewModelBuilder(ProductModelBuilder productModelBuilder,
                                     ProductItemViewModelBuilder productItemViewModelBuilder,
                                     RequestModelAccessor requestModelAccessor,
                                     ProductSearchService productSearchService,
                                     BaseProductService baseProductService,
                                     VariantService variantService)
 {
     _productModelBuilder         = productModelBuilder;
     _productItemViewModelBuilder = productItemViewModelBuilder;
     _requestModelAccessor        = requestModelAccessor;
     _productSearchService        = productSearchService;
     _baseProductService          = baseProductService;
     _variantService = variantService;
 }
コード例 #7
0
 public SearchResultTransformationService(
     BaseProductService baseProductService,
     VariantService variantService,
     FieldDefinitionService fieldDefinitionService,
     ProductModelBuilder productModelBuilder,
     UrlService urlService,
     CategoryService categoryService)
 {
     _baseProductService     = baseProductService;
     _variantService         = variantService;
     _fieldDefinitionService = fieldDefinitionService;
     _productModelBuilder    = productModelBuilder;
     _urlService             = urlService;
     _categoryService        = categoryService;
 }
コード例 #8
0
        private static ProductModel GetProduct(Guid systemId, IServiceScope scope,
                                               BaseProductService baseProductService, VariantService variantService,
                                               GlobalModel globalModel)
        {
            // Special treatment for scoped services https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#scoped-services-with-a-singleton-schema-lifetime
            // and make sure it is thread safe https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#thread-safety-with-scoped-services
            var productPageViewModelBuilder = scope.ServiceProvider.GetRequiredService <ProductPageViewModelBuilder>();
            var baseProduct = baseProductService.Get(systemId);

            if (baseProduct != null)
            {
                return(productPageViewModelBuilder.Build(baseProduct).MapTo <ProductModel>());
            }
            return(productPageViewModelBuilder.Build(variantService.Get(systemId)).MapTo <ProductModel>());
        }
コード例 #9
0
 public MediaMapper(BaseProductService baseProductService,
                    VariantService variantService,
                    FieldDefinitionService fieldDefinitionService,
                    MediaArchive mediaArchive,
                    IEnumerable <IFieldSetter> fieldSetters,
                    IMediaProfiler mediaProfiler,
                    string mediaUploadFolder)
 {
     _baseProductService     = baseProductService;
     _variantService         = variantService;
     _fieldDefinitionService = fieldDefinitionService;
     _mediaArchive           = mediaArchive;
     _mediaProfiler          = mediaProfiler;
     _fieldSetters           = fieldSetters.ToList();
     _uploadFolder           = mediaUploadFolder?.Replace('\\', '/').Trim('/');
 }
コード例 #10
0
 public CartViewModelBuilder(
     RequestModelAccessor requestModelAccessor,
     UrlService urlService,
     ChannelService channelService,
     CurrencyService currencyService,
     BaseProductService baseProductService,
     VariantService variantService,
     UnitOfMeasurementService unitOfMeasurementService)
 {
     _requestModelAccessor     = requestModelAccessor;
     _urlService               = urlService;
     _channelService           = channelService;
     _currencyService          = currencyService;
     _baseProductService       = baseProductService;
     _variantService           = variantService;
     _unitOfMeasurementService = unitOfMeasurementService;
 }
コード例 #11
0
 public ProductIndexDocumentBuilder(
     IndexDocumentBuilderDependencies dependencies,
     BaseProductService baseProductService,
     DisplayTemplateService displayTemplateService,
     FieldTemplateService fieldTemplateService,
     VariantService variantService,
     TemplateSettingService templateSettingService,
     ProductIndexingContext productIndexingContext,
     CategoryService categoryService,
     MostSoldDataHolder mostSoldDataHolder,
     CampaignDataHolder campaignDataHolder,
     CountryService countryService,
     PriceListService priceListService,
     PriceListItemService priceListItemService,
     ProductListService productListService,
     ProductListItemService productListItemService,
     FilterService filterService,
     FieldDefinitionService fieldDefinitionService,
     SearchPermissionService searchPermissionService,
     ContentBuilderService contentBuilderService,
     ChannelService channelService,
     LanguageService languageService)
     : base(dependencies)
 {
     _baseProductService      = baseProductService;
     _displayTemplateService  = displayTemplateService;
     _fieldTemplateService    = fieldTemplateService;
     _variantService          = variantService;
     _templateSettingService  = templateSettingService;
     _productIndexingContext  = productIndexingContext;
     _categoryService         = categoryService;
     _mostSoldDataHolder      = mostSoldDataHolder;
     _campaignDataHolder      = campaignDataHolder;
     _countryService          = countryService;
     _priceListService        = priceListService;
     _priceListItemService    = priceListItemService;
     _productListService      = productListService;
     _productListItemService  = productListItemService;
     _filterService           = filterService;
     _fieldDefinitionService  = fieldDefinitionService;
     _searchPermissionService = searchPermissionService;
     _contentBuilderService   = contentBuilderService;
     _channelService          = channelService;
     _languageService         = languageService;
 }
コード例 #12
0
 public ProductSearchServiceImpl(
     SearchService searchService,
     ProductModelBuilder productModelBuilder,
     BaseProductService baseProductService,
     VariantService variantService,
     FieldDefinitionService fieldDefinitionService,
     UrlService urlService,
     RequestModelAccessor requestModelAccessor,
     SearchQueryBuilderFactory searchQueryBuilderFactory,
     CategoryService categoryService)
 {
     _productModelBuilder       = productModelBuilder;
     _baseProductService        = baseProductService;
     _variantService            = variantService;
     _fieldDefinitionService    = fieldDefinitionService;
     _urlService                = urlService;
     _requestModelAccessor      = requestModelAccessor;
     _searchService             = searchService;
     _searchQueryBuilderFactory = searchQueryBuilderFactory;
     _categoryService           = categoryService;
 }
コード例 #13
0
 public DeploymentController(
     DeploymentViewModelBuilder deploymentViewModelBuilder,
     FolderService folderService,
     ChannelService channelService,
     AssortmentService assortmentService,
     IPackageService packageService,
     IPackage package,
     WebsiteService websiteService,
     StructureInfoService structureInfoService,
     SettingService settingService,
     DomainNameService domainNameService,
     SlugifyService slugifyService,
     ILogger <DeploymentController> logger,
     InventoryService inventoryService,
     PriceListService priceListService,
     CategoryService categoryService,
     BaseProductService baseProductService,
     VariantService variantService,
     MarketService marketService)
 {
     _deploymentViewModelBuilder = deploymentViewModelBuilder;
     _folderService        = folderService;
     _channelService       = channelService;
     _assortmentService    = assortmentService;
     _packageService       = packageService;
     _package              = package;
     _websiteService       = websiteService;
     _structureInfoService = structureInfoService;
     _settingService       = settingService;
     _domainNameService    = domainNameService;
     _slugifyService       = slugifyService;
     _logger             = logger;
     _inventoryService   = inventoryService;
     _priceListService   = priceListService;
     _categoryService    = categoryService;
     _baseProductService = baseProductService;
     _variantService     = variantService;
     _marketService      = marketService;
 }
コード例 #14
0
        public CategoryType(CategoryService categoryService, BaseProductService baseProductService,
                            UrlService urlService, WebsiteService websiteService, RouteInfoService routeInfoService)
        {
            Name        = "Category";
            Description = "A category";
            Field(p => p.SystemId, type: typeof(IdGraphType)).Description("The system Id");
            // Field(p => p.ParentSystemId, type: typeof(IdGraphType)).Description("The parent category system Id");
            Field(p => p.Slug).Description("The category's slug url")
            .Argument <GlobalInputType>("global")
            .Resolve(context =>
            {
                var globalModel = context.GetArgument <GlobalModel>("global");
                var category    = categoryService.Get(context.Source.SystemId);
                return(urlService.GetUrl(category, new CategoryUrlArgs(globalModel.ChannelSystemId)));
            });

            Field <StringGraphType>(nameof(CategoryModel.Name), "The category name",
                                    arguments: new QueryArguments(
                                        new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            }
                                        ),
                                    resolve: context =>
            {
                var category    = categoryService.Get(context.Source.SystemId);
                var globalModel = context.GetArgument <GlobalModel>("global");
                var culture     = CultureInfo.GetCultureInfo(globalModel.CurrentUICulture);
                return(category.GetEntityName(true, culture) ?? category.Id ?? "general.NameIsMissing".AsAngularResourceString());
            });

            Field <ListGraphType <StringGraphType> >(nameof(CategoryModel.Images), "The category's images",
                                                     resolve: context =>
            {
                var source = categoryService.Get(context.Source.SystemId);
                return(source.Fields.GetImageUrls((i) => {
                    return new ImageSize()
                    {
                        MinSize = new Size(200, 200), MaxSize = new Size(400, 400)
                    };
                }));
            });

            FieldAsync <PageInfoProductType>(nameof(CategoryModel.Products), description: "Products belong to the category",
                                             arguments: new QueryArguments(
                                                 new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                                                 new QueryArgument <IntGraphType> {
                Name = "take"
            },
                                                 new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            }
                                                 ),
                                             resolve: async context =>
            {
                return(await ProductQuery.SearchAsync(
                           context.GetArgument <GlobalModel>("global"),
                           context.Source.SystemId,
                           routeInfoService,
                           string.Empty,
                           context.GetArgument("take", 8),
                           context.GetArgument("offset", 0),
                           context.RequestServices
                           ));
            });

            Field <PageInfoCategoryType>(nameof(CategoryModel.Categories), description: "Sub categories",
                                         arguments: new QueryArguments(
                                             new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                                             new QueryArgument <IntGraphType> {
                Name = "take"
            }
                                             ),
                                         resolve: context =>
                                         new PageInfoModel <Category, CategoryModel>(categoryService.GetChildCategories(context.Source.SystemId),
                                                                                     context.GetArgument("offset", 0), context.GetArgument("take", 10)));

            // Field<CategoryType>(nameof(CategoryModel.ParentCategory), description: "Parent category",
            //     resolve: context =>
            //                 categoryService.Get(context.Source.ParentSystemId)?.MapTo<CategoryModel>());
        }
コード例 #15
0
        public LitiumQuery(BaseProductService baseProductService,
                           VariantService variantService,
                           ChannelService channelService,
                           MarketService marketService,
                           CountryService countryService,
                           LanguageService languageService,
                           RoutingHelperService routingHelperService,
                           CategoryService categoryService,
                           PageService pageService,
                           WebsiteService websiteService,
                           RouteInfoService routeInfoService,
                           DataService dataService)
        {
            Name = "LitiumQuery";

            Field <WebsiteType>(
                "website",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "systemId"
            }
                    ),
                resolve: (context) =>
            {
                var systemId = context.GetArgument <Guid>("systemId");
                var logoUrl  = websiteService.Get(systemId).Fields
                               .GetValue <Guid?>(AcceleratorWebsiteFieldNameConstants.LogotypeMain).Value
                               .MapTo <Web.Models.ImageModel>().GetUrlToImage(System.Drawing.Size.Empty, new System.Drawing.Size(-1, 50)).Url;
                return(new WebsiteModel()
                {
                    LogoUrl = logoUrl,
                    SystemId = systemId
                });
            }
                );

            Field <GlobalType>(
                "global",
                resolve: (context) =>
            {
                var channel   = channelService.GetAll().First();
                var market    = marketService.Get(channel.MarketSystemId.Value);
                var country   = countryService.Get(channel.CountryLinks.First().CountrySystemId);
                var culture   = languageService.Get(channel.WebsiteLanguageSystemId.Value);
                var uiCulture = languageService.Get(channel.ProductLanguageSystemId.Value);

                return(new GlobalModel()
                {
                    ChannelSystemId = channel.SystemId,
                    WebsiteSystemId = channel.WebsiteSystemId.Value,
                    AssortmentSystemId = market.AssortmentSystemId.Value,
                    CountrySystemId = country.SystemId,
                    CurrencySystemId = country.CurrencySystemId,
                    CurrentCulture = culture.Id,
                    CurrentUICulture = uiCulture.Id,
                });
            }
                );

            Field <CategoryType>(
                "category",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "systemId", Description = "id of the category, will be override if slug has value"
            },
                    new QueryArgument <GlobalInputType> {
                Name = "global"
            },
                    new QueryArgument <ListGraphType <StringGraphType> > {
                Name = "slug", Description = "category slug urls"
            }
                    ),
                resolve: context =>
            {
                var categoryId = context.GetArgument <Guid>("systemId");
                var slug       = context.GetArgument <string[]>("slug");
                if (slug != null && slug.Any())
                {
                    var globalModel = context.GetArgument <GlobalModel>("global");
                    return(GetCategoryFromSlug(slug, globalModel, routingHelperService, categoryService));
                }
                return(categoryService.Get(categoryId).MapTo <CategoryModel>());
            }
                );

            FieldAsync <PageInfoCategoryType>(
                "searchCategory",
                arguments: new QueryArguments(
                    new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                    new QueryArgument <IntGraphType> {
                Name = "take"
            },
                    new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            },
                    new QueryArgument <StringGraphType> {
                Name = "query", Description = "The search query"
            }
                    ),
                resolve: async context =>
            {
                return(await CategoryQuery.SearchAsync(
                           context.GetArgument <GlobalModel>("global"),
                           routeInfoService,
                           context.GetArgument <string>("query") ?? string.Empty,
                           context.GetArgument("take", 8),
                           context.GetArgument("offset", 0),
                           context.RequestServices
                           ));
            }
                );

            Field <ProductType>(
                "product",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "systemId", Description = "id of the product"
            },
                    new QueryArgument <StringGraphType> {
                Name = "slug", Description = "Product's slug url"
            },
                    new QueryArgument <GlobalInputType> {
                Name = "global"
            }
                    ),
                resolve: context =>
            {
                var systemId    = context.GetArgument <Guid>("systemId");
                var slug        = context.GetArgument <string>("slug");
                var globalModel = context.GetArgument <GlobalModel>("global");
                if (!string.IsNullOrEmpty(slug))
                {
                    systemId = GetProductSystemIdFromSlug(slug, globalModel, routingHelperService);
                }
                // Special treatment for scoped services https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#scoped-services-with-a-singleton-schema-lifetime
                // and make sure it is thread safe https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#thread-safety-with-scoped-services
                using var scope = context.RequestServices.CreateScope();
                return(GetProduct(systemId, scope, baseProductService, variantService, globalModel));
            }
                );

            FieldAsync <PageInfoProductType>(
                "products",
                arguments: new QueryArguments(
                    new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                    new QueryArgument <IntGraphType> {
                Name = "take"
            },
                    new QueryArgument <IdGraphType> {
                Name = "parentCategorySystemId", Description = "The optional parent category system id"
            },
                    new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            },
                    new QueryArgument <StringGraphType> {
                Name = "query", Description = "The search query"
            }
                    ),
                resolve: async context =>
            {
                return(await ProductQuery.SearchAsync(
                           context.GetArgument <GlobalModel>("global"),
                           context.GetArgument <Guid?>("parentCategorySystemId"),
                           routeInfoService,
                           context.GetArgument <string>("query") ?? string.Empty,
                           context.GetArgument("take", 8),
                           context.GetArgument("offset", 0),
                           context.RequestServices
                           ));
            }
                );

            Field <PageType>(
                "page",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "systemId", Description = "Id of the page. Can be empty GUID, the website's homepage will be returned in that case, where WebsiteSystemId should have value."
            },
                    new QueryArgument <ListGraphType <StringGraphType> > {
                Name = "slug", Description = "Page's slugs, will override systemId if available"
            },
                    new QueryArgument <GlobalInputType> {
                Name = "global", Description = "Global context, which is needed to get page from slug"
            }
                    ),
                resolve: context =>
            {
                var slug        = context.GetArgument <string[]>("slug");
                var globalModel = context.GetArgument <GlobalModel>("global");
                routeInfoService.Setup(globalModel, null);
                if (slug != null && slug.Any())
                {
                    return(GetPageFromSlug(slug, globalModel, pageService, routingHelperService));
                }

                var systemId = context.GetArgument <Guid?>("systemId");
                if (systemId.HasValue && systemId.Value != Guid.Empty)
                {
                    return(pageService.Get(systemId.Value)?.MapTo <PageModel>());
                }
                return(pageService.GetChildPages(Guid.Empty, globalModel.WebsiteSystemId).FirstOrDefault()?.MapTo <PageModel>());
            }
                );

            FieldAsync <PageInfoPageType>(
                "searchPage",
                arguments: new QueryArguments(
                    new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                    new QueryArgument <IntGraphType> {
                Name = "take"
            },
                    new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            },
                    new QueryArgument <StringGraphType> {
                Name = "query", Description = "The search query"
            }
                    ),
                resolve: async context =>
            {
                return(await PageQuery.SearchAsync(
                           context.GetArgument <GlobalModel>("global"),
                           routeInfoService,
                           context.GetArgument <string>("query") ?? string.Empty,
                           context.GetArgument("take", 8),
                           context.GetArgument("offset", 0),
                           context.RequestServices
                           ));
            }
                );

            Field <ContentType>(
                "content",
                arguments: new QueryArguments(
                    new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            },
                    new QueryArgument <ListGraphType <StringGraphType> > {
                Name = "slug", Description = "The slug array"
            }
                    ),
                resolve: context =>
            {
                var slug        = context.GetArgument <string[]>("slug");
                var globalModel = context.GetArgument <GlobalModel>("global");
                routeInfoService.Setup(globalModel, null);

                var systemId = GetProductSystemIdFromSlug(slug[slug.Length - 1], globalModel, routingHelperService);
                if (systemId != Guid.Empty)
                {
                    // Special treatment for scoped services https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#scoped-services-with-a-singleton-schema-lifetime
                    // and make sure it is thread safe https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#thread-safety-with-scoped-services
                    using var scope = context.RequestServices.CreateScope();
                    return(GetProduct(systemId, scope, baseProductService, variantService, globalModel));
                }

                var category = GetCategoryFromSlug(slug, globalModel, routingHelperService, categoryService);
                if (category != null)
                {
                    return(category);
                }
                return(GetPageFromSlug(slug, globalModel, pageService, routingHelperService));
            }
                );
        }
コード例 #16
0
 public UrlInfoController(BaseProductService baseProductService, ModuleCMS moduleCms, CategoryService categoryService)
 {
     _baseProductService = baseProductService;
     _moduleCms          = moduleCms;
     _categoryService    = categoryService;
 }