From 6a15605eedb1197313fcff545e00729d030cf6ef Mon Sep 17 00:00:00 2001 From: Artem Dudarev Date: Tue, 12 Nov 2024 10:44:36 +0200 Subject: [PATCH] Refactoring --- .../Commands/AddQuoteItemsCommandHandler.cs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/AddQuoteItemsCommandHandler.cs b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/AddQuoteItemsCommandHandler.cs index 8ca5f63a..82cfd435 100644 --- a/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/AddQuoteItemsCommandHandler.cs +++ b/src/VirtoCommerce.QuoteModule.ExperienceApi/Commands/AddQuoteItemsCommandHandler.cs @@ -30,8 +30,8 @@ protected override async Task UpdateQuoteAsync(QuoteRequest quote, AddQuoteItems StoreId = quote.StoreId, CurrencyCode = quote.Currency, ObjectIds = productIds, - IncludeFields = new string[] - { + IncludeFields = + [ "__object", "price", "images", @@ -39,7 +39,7 @@ protected override async Task UpdateQuoteAsync(QuoteRequest quote, AddQuoteItems "description", "slug", "outlines" - }, + ], EvaluatePromotions = false, }; @@ -57,12 +57,13 @@ protected virtual void AddQuoteItems(QuoteRequest quote, AddQuoteItemsCommand re { var quoteItem = AbstractTypeFactory.TryCreateInstance(); - var product = productsByIds.GetValueSafe(newQuoteItem.ProductId); - var price = product?.AllPrices.FirstOrDefault(); - + quoteItem.ProductId = newQuoteItem.ProductId; quoteItem.Name = newQuoteItem.Name; + quoteItem.Comment = newQuoteItem.Comment; + quoteItem.Quantity = newQuoteItem.Quantity; + quoteItem.Currency = quote.Currency; - quoteItem.ProductId = newQuoteItem.ProductId; + var product = productsByIds.GetValueSafe(newQuoteItem.ProductId); if (product != null) { quoteItem.Name = product.IndexedProduct.Name; @@ -73,14 +74,10 @@ protected virtual void AddQuoteItems(QuoteRequest quote, AddQuoteItemsCommand re quoteItem.TaxType = product.IndexedProduct.TaxType; } + var price = product?.AllPrices.FirstOrDefault(); quoteItem.ListPrice = price?.ListPrice.InternalAmount ?? 0; quoteItem.SalePrice = price?.SalePrice.InternalAmount ?? 0; - quoteItem.Comment = newQuoteItem.Comment; - quoteItem.Currency = quote.Currency; - - quoteItem.Quantity = newQuoteItem.Quantity; - var tierPrice = AbstractTypeFactory.TryCreateInstance(); tierPrice.Price = newQuoteItem.Price ?? quoteItem.SalePrice; tierPrice.Quantity = newQuoteItem.Quantity;