Skip to content

Commit

Permalink
VCST-2258: Added GraphQL mutation for Quote DynamicProperties (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurensBit authored Nov 14, 2024
1 parent d54a5c6 commit f028336
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
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"
);
}
}
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";
}
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
}
}

0 comments on commit f028336

Please sign in to comment.