Fix mvc calls to grpc

This commit is contained in:
ericuss 2019-08-29 13:13:10 +02:00
parent 9bb640aee4
commit 4398b25fc1
5 changed files with 10 additions and 19 deletions

View File

@ -126,11 +126,13 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers
// Step 3: Search if exist product into basket
var product = currentBasket.Items.SingleOrDefault(i => i.ProductId == item.Id.ToString());
if(product != null){
if (product != null)
{
// Step 4: Update quantity for product
product.Quantity += data.Quantity;
}
else{
else
{
// Step 4: Merge current status with new product
currentBasket.Items.Add(new BasketDataItem()
{

View File

@ -46,7 +46,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
var request = MapToCustomerBasketRequest(currentBasket);
_logger.LogDebug("Grpc update basket request {@request}", request);
return client.UpdateBasketAsync(request);
return await client.UpdateBasketAsync(request);
});
}

View File

@ -63,8 +63,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
basketCheckout.RequestId = (Guid.TryParse(requestId, out Guid guid) && guid != Guid.Empty) ?
guid : basketCheckout.RequestId;
_logger.LogInformation("----- CheckoutAsync userId: {userId} ", userId);
var basket = await _repository.GetBasketAsync(userId);
if (basket == null)
@ -72,14 +70,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
return BadRequest();
}
_logger.LogInformation("----- CheckoutAsync basket: {@basket} ", basket);
_logger.LogInformation("----- CheckoutAsync user identity: {User} ", string.Join(':', ((ClaimsIdentity)User.Identity).Claims.Select(c => c.Type + " " + c.Value)));
var userName = User.FindFirst(x => x.Type == ClaimTypes.Name).Value;
_logger.LogInformation("----- CheckoutAsync userName: {@userName} ", userName);
var eventMessage = new UserCheckoutAcceptedIntegrationEvent(userId, userName, basketCheckout.City, basketCheckout.Street,
basketCheckout.State, basketCheckout.Country, basketCheckout.ZipCode, basketCheckout.CardNumber, basketCheckout.CardHolderName,
basketCheckout.CardExpiration, basketCheckout.CardSecurityNumber, basketCheckout.CardTypeId, basketCheckout.Buyer, basketCheckout.RequestId, basket);
@ -89,8 +81,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
// order creation process
try
{
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", eventMessage.Id, Program.AppName, eventMessage);
_eventBus.Publish(eventMessage);
}
catch (Exception ex)

View File

@ -6,7 +6,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
{
public string BuyerId { get; set; }
public List<BasketItem> Items { get; set; }
public List<BasketItem> Items { get; set; } = new List<BasketItem>();
public CustomerBasket()
{
@ -16,7 +16,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
public CustomerBasket(string customerId)
{
BuyerId = customerId;
Items = new List<BasketItem>();
}
}
}