From f0283362a72329bd36551eec06763117df9ea909 Mon Sep 17 00:00:00 2001 From: LaurensBit Date: Thu, 14 Nov 2024 14:46:17 +0100 Subject: [PATCH] VCST-2258: Added GraphQL mutation for Quote DynamicProperties (#126) --- .../UpdateQuoteDynamicPropertiesCommand.cs | 22 +++++++++++++ ...ateQuoteDynamicPropertiesCommandBuilder.cs | 13 ++++++++ ...ateQuoteDynamicPropertiesCommandHandler.cs | 31 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommand.cs create mode 100644 src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandBuilder.cs create mode 100644 src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandHandler.cs diff --git a/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommand.cs b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommand.cs new file mode 100644 index 00000000..417dcee1 --- /dev/null +++ b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommand.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using GraphQL.Types; +using VirtoCommerce.Xapi.Core.Models; +using VirtoCommerce.Xapi.Core.Schemas; + +namespace VirtoCommerce.QuoteModule.ExperienceApi.Commands; + +public class UpdateQuoteDynamicPropertiesCommand : QuoteCommand +{ + public List DynamicProperties { get; set; } = default!; +} + +public class UpdateQuoteDynamicPropertiesCommandType : QuoteCommandType +{ + public UpdateQuoteDynamicPropertiesCommandType() + { + Field>>( + "dynamicProperties", + "Dynamic properties" + ); + } +} diff --git a/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandBuilder.cs b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandBuilder.cs new file mode 100644 index 00000000..52c27f37 --- /dev/null +++ b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandBuilder.cs @@ -0,0 +1,13 @@ +using MediatR; +using Microsoft.AspNetCore.Authorization; + +namespace VirtoCommerce.QuoteModule.ExperienceApi.Commands; + +public class UpdateQuoteDynamicPropertiesCommandBuilder(IMediator mediator, IAuthorizationService authorizationService) + : QuoteCommandBuilder( + mediator, + authorizationService + ) +{ + protected override string Name => "updateQuoteDynamicProperties"; +} diff --git a/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandHandler.cs b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandHandler.cs new file mode 100644 index 00000000..298b07e8 --- /dev/null +++ b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandHandler.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using VirtoCommerce.Platform.Core.Settings; +using VirtoCommerce.QuoteModule.Core.Models; +using VirtoCommerce.QuoteModule.Core.Services; +using VirtoCommerce.QuoteModule.ExperienceApi.Aggregates; +using VirtoCommerce.Xapi.Core.Services; + +namespace VirtoCommerce.QuoteModule.ExperienceApi.Commands; + +public class UpdateQuoteDynamicPropertiesCommandHandler( + IQuoteRequestService quoteRequestService, + IQuoteAggregateRepository quoteAggregateRepository, + ISettingsManager settingsManager, + IDynamicPropertyUpdaterService dynamicPropertyUpdaterService +) + : QuoteCommandHandler( + quoteRequestService, + quoteAggregateRepository, + settingsManager + ) +{ + protected override async Task UpdateQuoteAsync(QuoteRequest quote, UpdateQuoteDynamicPropertiesCommand request) + { + await dynamicPropertyUpdaterService.UpdateDynamicPropertyValues(quote, request.DynamicProperties); + } + + protected override void UpdateQuote(QuoteRequest quote, UpdateQuoteDynamicPropertiesCommand request) + { + // Empty implementation of obsolete abstract method + } +}