Skip to content

Commit

Permalink
fix: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ksavosteev committed Dec 6, 2024
1 parent 0e0f5c0 commit 285556a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/VirtoCommerce.XCart.Core/CartAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ public virtual void SetLineItemTierPrice(ProductPrice productPrice, int quantity
}
}

public virtual Task<CartAggregate> UpdateConfiguredItemAsync(string lineItemId, LineItem configuredItem)
public virtual Task<CartAggregate> UpdateConfiguredLineItemAsync(string lineItemId, LineItem configuredItem)
{
ArgumentNullException.ThrowIfNull(lineItemId);
ArgumentNullException.ThrowIfNull(configuredItem);
Expand Down Expand Up @@ -1145,7 +1145,7 @@ public virtual async Task<CartAggregate> UpdateConfiguredLineItemPrice(IList<Lin
return this;
}

var configProducts = await _cartProductService.GetCartProductsByIdsAsync(this, configProductsIds.ToArray());
var configProducts = await _cartProductService.GetCartProductsByIdsAsync(this, configProductsIds);

foreach (var configurationLineItem in configuredItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace VirtoCommerce.XCart.Core.Commands;

public class ChangeCartConfiguredItemCommand : CartCommand
public class ChangeCartConfiguredLineItemCommand : CartCommand
{
public string LineItemId { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GraphQL.Types;
using GraphQL.Types;

namespace VirtoCommerce.XCart.Core.Schemas
{
Expand All @@ -8,7 +8,7 @@ public InputChangeCartConfiguredItemType()
{
Field<NonNullGraphType<StringGraphType>>("lineItemId", "Line item Id");
Field<IntGraphType>("quantity", "Quantity");
Field<ListGraphType<ConfigurationSectionInput>>("configurationSections");
Field<ListGraphType<ConfigurationSectionInput>>("configurationSections", "Configuration sections");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

namespace VirtoCommerce.XCart.Data.Commands;

public class ChangeCartConfiguredItemCommandHandler : CartCommandHandler<ChangeCartConfiguredItemCommand>
public class ChangeCartConfiguredLineItemCommandHandler : CartCommandHandler<ChangeCartConfiguredLineItemCommand>
{
private readonly IMediator _mediator;

public ChangeCartConfiguredItemCommandHandler(ICartAggregateRepository cartAggregateRepository, IMediator mediator)
public ChangeCartConfiguredLineItemCommandHandler(ICartAggregateRepository cartAggregateRepository, IMediator mediator)
: base(cartAggregateRepository)
{
_mediator = mediator;
}

public override async Task<CartAggregate> Handle(ChangeCartConfiguredItemCommand request, CancellationToken cancellationToken)
public override async Task<CartAggregate> Handle(ChangeCartConfiguredLineItemCommand request, CancellationToken cancellationToken)
{
var cartAggregate = await GetOrCreateCartFromCommandAsync(request);

var lineItem = GetConfiguredLineItem(request, cartAggregate);
if (lineItem != null)
{
var createConfigurableProductCommand = new CreateConfiguredLineItemCommand
var command = new CreateConfiguredLineItemCommand
{
StoreId = request.StoreId,
UserId = request.UserId,
Expand All @@ -39,16 +39,16 @@ public override async Task<CartAggregate> Handle(ChangeCartConfiguredItemCommand
Quantity = request.Quantity ?? lineItem.Quantity,
};

var mediatorResult = await _mediator.Send(createConfigurableProductCommand, cancellationToken);
await cartAggregate.UpdateConfiguredItemAsync(lineItem.Id, mediatorResult.Item);
var mediatorResult = await _mediator.Send(command, cancellationToken);
await cartAggregate.UpdateConfiguredLineItemAsync(lineItem.Id, mediatorResult.Item);

return await SaveCartAsync(cartAggregate);
}

return cartAggregate;
}

private static LineItem GetConfiguredLineItem(ChangeCartConfiguredItemCommand request, CartAggregate cartAggregate)
private static LineItem GetConfiguredLineItem(ChangeCartConfiguredLineItemCommand request, CartAggregate cartAggregate)
{
return cartAggregate.Cart.Items.FirstOrDefault(x => x.Id == request.LineItemId && x.IsConfigured);
}
Expand Down
2 changes: 1 addition & 1 deletion src/VirtoCommerce.XCart.Data/Schemas/PurchaseSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void Build(ISchema schema)
.Argument(GraphTypeExtenstionHelper.GetActualComplexType<NonNullGraphType<InputChangeCartConfiguredItemType>>(), SchemaConstants.CommandName)
.ResolveSynchronizedAsync(CartPrefix, "userId", _distributedLockService, async context =>
{
var cartCommand = context.GetCartCommand<ChangeCartConfiguredItemCommand>();
var cartCommand = context.GetCartCommand<ChangeCartConfiguredLineItemCommand>();

await CheckAuthByCartCommandAsync(context, cartCommand);

Expand Down

0 comments on commit 285556a

Please sign in to comment.