-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VCST-2258: Added GraphQL mutation for Quote DynamicProperties (#126)
- Loading branch information
1 parent
d54a5c6
commit f028336
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DynamicPropertyValue> DynamicProperties { get; set; } = default!; | ||
} | ||
|
||
public class UpdateQuoteDynamicPropertiesCommandType : QuoteCommandType<UpdateQuoteDynamicPropertiesCommand> | ||
{ | ||
public UpdateQuoteDynamicPropertiesCommandType() | ||
{ | ||
Field<NonNullGraphType<ListGraphType<InputDynamicPropertyValueType>>>( | ||
"dynamicProperties", | ||
"Dynamic properties" | ||
); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...Commerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using MediatR; | ||
using Microsoft.AspNetCore.Authorization; | ||
|
||
namespace VirtoCommerce.QuoteModule.ExperienceApi.Commands; | ||
|
||
public class UpdateQuoteDynamicPropertiesCommandBuilder(IMediator mediator, IAuthorizationService authorizationService) | ||
: QuoteCommandBuilder<UpdateQuoteDynamicPropertiesCommand, UpdateQuoteDynamicPropertiesCommandType>( | ||
mediator, | ||
authorizationService | ||
) | ||
{ | ||
protected override string Name => "updateQuoteDynamicProperties"; | ||
} |
31 changes: 31 additions & 0 deletions
31
...Commerce.QuoteModule.ExperienceApi/Commands/UpdateQuoteDynamicPropertiesCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<UpdateQuoteDynamicPropertiesCommand>( | ||
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 | ||
} | ||
} |