Browse Source

Merge branch 'features/grpc' of https://github.com/dotnet-architecture/eShopOnContainers into features/grpc

features/migration-dotnet3
eiximenis 5 years ago
parent
commit
b86771e084
56 changed files with 427 additions and 365 deletions
  1. +6
    -6
      src/ApiGateways/ApiGw-Base/Dockerfile
  2. +1
    -0
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Config/UrlsConfig.cs
  3. +15
    -37
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs
  4. +15
    -11
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/CatalogService.cs
  5. +73
    -0
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs
  6. +10
    -33
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderingService.cs
  7. +0
    -5
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json
  8. +1
    -0
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json
  9. +6
    -6
      src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs
  10. +49
    -61
      src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs
  11. +18
    -18
      src/ApiGateways/Web.Bff.Shopping/aggregator/Services/CatalogService.cs
  12. +73
    -0
      src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs
  13. +10
    -32
      src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderingService.cs
  14. +2
    -2
      src/ApiGateways/Web.Bff.Shopping/aggregator/Startup.cs
  15. +0
    -10
      src/Services/Basket/Basket.API/Controllers/BasketController.cs
  16. +0
    -2
      src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs
  17. +0
    -4
      src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs
  18. +1
    -2
      src/Services/Basket/Basket.API/Model/CustomerBasket.cs
  19. +31
    -21
      src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs
  20. +0
    -4
      src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs
  21. +0
    -2
      src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
  22. +0
    -2
      src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
  23. +1
    -7
      src/Services/Catalog/Catalog.API/Proto/catalog.proto
  24. +0
    -3
      src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs
  25. +0
    -2
      src/Services/Marketing/Marketing.API/IntegrationEvents/Handlers/UserLocationUpdatedIntegrationEventHandler.cs
  26. +0
    -2
      src/Services/Ordering/Ordering.API/Application/Behaviors/ValidatorBehavior.cs
  27. +0
    -2
      src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs
  28. +0
    -1
      src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs
  29. +7
    -8
      src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs
  30. +0
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs
  31. +0
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs
  32. +0
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSuccededIntegrationEventHandler.cs
  33. +0
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs
  34. +0
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs
  35. +2
    -8
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs
  36. +0
    -4
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs
  37. +3
    -3
      src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs
  38. +1
    -1
      src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs
  39. +7
    -6
      src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile
  40. +0
    -2
      src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs
  41. +4
    -3
      src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs
  42. +31
    -7
      src/Services/Ordering/Ordering.Infrastructure/EntityConfigurations/OrderEntityTypeConfiguration.cs
  43. +20
    -5
      src/Services/Ordering/Ordering.Infrastructure/EntityConfigurations/OrderItemEntityTypeConfiguration.cs
  44. +22
    -6
      src/Services/Ordering/Ordering.Infrastructure/EntityConfigurations/PaymentMethodEntityTypeConfiguration.cs
  45. +9
    -1
      src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs
  46. +6
    -6
      src/Services/Ordering/Ordering.SignalrHub/Dockerfile
  47. +0
    -2
      src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs
  48. +0
    -2
      src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs
  49. +0
    -2
      src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs
  50. +0
    -2
      src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs
  51. +0
    -2
      src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
  52. +0
    -2
      src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs
  53. +0
    -4
      src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs
  54. +0
    -2
      src/Web/WebMVC/Controllers/AccountController.cs
  55. +2
    -2
      src/Web/WebMVC/Controllers/CartController.cs
  56. +1
    -0
      src/docker-compose.override.yml

+ 6
- 6
src/ApiGateways/ApiGw-Base/Dockerfile View File

@ -6,14 +6,14 @@ FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /src
COPY scripts scripts/
COPY src/ApiGateways/*/*.csproj /src/csproj-files/
COPY src/ApiGateways/*/*/*.csproj /src/csproj-files/
COPY src/BuildingBlocks/*/*/*.csproj /src/csproj-files/
COPY src/Services/*/*/*.csproj /src/csproj-files/
COPY src/Web/*/*.csproj /src/csproj-files/
COPY ApiGateways/*/*.csproj csproj-files/
COPY ApiGateways/*/*/*.csproj csproj-files/
COPY BuildingBlocks/*/*/*.csproj csproj-files/
COPY Services/*/*/*.csproj csproj-files/
COPY Web/*/*.csproj csproj-files/
COPY . .
WORKDIR /src/src/ApiGateways/ApiGw-Base/
WORKDIR /src/ApiGateways/ApiGw-Base/
RUN dotnet publish -c Release -o /app
FROM build AS publish


+ 1
- 0
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Config/UrlsConfig.cs View File

@ -28,6 +28,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config
public string Catalog { get; set; }
public string Orders { get; set; }
public string GrpcBasket { get; set; }
public string GrpcCatalog { get; set; }
public string GrpcOrdering { get; set; }
}
}

+ 15
- 37
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs View File

@ -27,50 +27,28 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
public async Task<BasketData> GetById(string id)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using (var httpClientHandler = new HttpClientHandler())
return await GrpcCallerService.CallService(_urls.GrpcBasket, async httpClient =>
{
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };
using (var httpClient = new HttpClient(httpClientHandler))
{
//httpClient.BaseAddress = new Uri("http://10.0.75.1:5580");
httpClient.BaseAddress = new Uri(_urls.GrpcBasket);
_logger.LogDebug("Creating grpc client for basket {@httpClient.BaseAddress} ", httpClient.BaseAddress);
var client = GrpcClient.Create<Basket.BasketClient>(httpClient);
_logger.LogDebug("grpc client created, request = {@id}", id);
try
{
var response = await client.GetBasketByIdAsync(new BasketRequest { Id = id });
var client = GrpcClient.Create<Basket.BasketClient>(httpClient);
_logger.LogDebug("grpc client created, request = {@id}", id);
var response = await client.GetBasketByIdAsync(new BasketRequest { Id = id });
_logger.LogDebug("grpc response {@response}", response);
_logger.LogDebug("grpc response {@response}", response);
return MapToBasketData(response);
}
catch (RpcException e)
{
_logger.LogError($"Error calling via grpc: {e.Status} - {e.Message}");
}
}
}
return null;
return MapToBasketData(response);
});
}
public async Task UpdateAsync(BasketData currentBasket)
{
_httpClient.BaseAddress = new Uri(_urls.Basket + UrlsConfig.BasketOperations.UpdateBasket());
var client = GrpcClient.Create<Basket.BasketClient>(_httpClient);
var request = MapToCustomerBasketRequest(currentBasket);
await GrpcCallerService.CallService(_urls.GrpcBasket, async httpClient =>
{
var client = GrpcClient.Create<Basket.BasketClient>(httpClient);
_logger.LogDebug("Grpc update basket currentBasket {@currentBasket}", currentBasket);
var request = MapToCustomerBasketRequest(currentBasket);
_logger.LogDebug("Grpc update basket request {@request}", request);
await client.UpdateBasketAsync(request);
return client.UpdateBasketAsync(request);
});
}
private BasketData MapToBasketData(CustomerBasketResponse customerBasketRequest)


+ 15
- 11
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/CatalogService.cs View File

@ -3,9 +3,8 @@ using Grpc.Net.Client;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using static CatalogApi.Catalog;
@ -25,21 +24,26 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
public async Task<CatalogItem> GetCatalogItemAsync(int id)
{
_httpClient.BaseAddress = new Uri(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemById(id));
var client = GrpcClient.Create<CatalogClient>(_httpClient);
var request = new CatalogItemRequest { Id = id };
var response = await client.GetItemByIdAsync(request);
return MapToCatalogItemResponse(response);
return await GrpcCallerService.CallService(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemById(id), async httpClient =>
{
var client = GrpcClient.Create<CatalogClient>(_httpClient);
var request = new CatalogItemRequest { Id = id };
var response = await client.GetItemByIdAsync(request);
return MapToCatalogItemResponse(response);
});
}
public async Task<IEnumerable<CatalogItem>> GetCatalogItemsAsync(IEnumerable<int> ids)
{
var stringContent = await _httpClient.GetStringAsync(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemsById(ids));
var catalogItems = JsonConvert.DeserializeObject<CatalogItem[]>(stringContent);
return catalogItems;
return await GrpcCallerService.CallService(_urls.GrpcCatalog, async httpClient =>
{
var client = GrpcClient.Create<CatalogClient>(httpClient);
var request = new CatalogItemsRequest { Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10 };
var response = await client.GetItemsByIdsAsync(request);
return response.Data.Select(this.MapToCatalogItemResponse);
});
}
private CatalogItem MapToCatalogItemResponse(CatalogItemResponse catalogItemResponse)


+ 73
- 0
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/GrpcCallerService.cs View File

@ -0,0 +1,73 @@
using System.Net.Http;
using System.Threading.Tasks;
using System;
using Grpc.Core;
using Serilog;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
{
public static class GrpcCallerService
{
public static async Task<TResponse> CallService<TResponse>(string urlGrpc, Func<HttpClient, Task<TResponse>> func)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
};
using var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(urlGrpc)
};
Log.Information("Creating grpc client base address urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress} ", urlGrpc, httpClient.BaseAddress);
try
{
return await func(httpClient);
}
catch (RpcException e)
{
Log.Error($"Error calling via grpc: {e.Status} - {e.Message}");
}
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
return default;
}
public static async Task CallService(string urlGrpc, Func<HttpClient, Task> func)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
};
using var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(urlGrpc)
};
Log.Debug("Creating grpc client base address {@httpClient.BaseAddress} ", httpClient.BaseAddress);
try
{
await func(httpClient);
}
catch (RpcException e)
{
Log.Error($"Error calling via grpc: {e.Status} - {e.Message}");
}
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
}
}
}

+ 10
- 33
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderingService.cs View File

@ -3,12 +3,10 @@ using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using GrpcOrdering;
using Grpc.Core;
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
{
@ -27,43 +25,21 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
public async Task<OrderData> GetOrderDraftAsync(BasketData basketData)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using (var httpClientHandler = new HttpClientHandler())
return await GrpcCallerService.CallService(_urls.GrpcOrdering, async httpClient =>
{
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };
using (var httpClient = new HttpClient(httpClientHandler))
{
httpClient.BaseAddress = new Uri(_urls.GrpcOrdering);
var client = GrpcClient.Create<OrderingGrpc.OrderingGrpcClient>(httpClient);
_logger.LogDebug(" grpc client created, basketData={@basketData}", basketData);
_logger.LogDebug(" Creating grpc client for ordering {@httpClient.BaseAddress}", httpClient.BaseAddress);
var command = MapToOrderDraftCommand(basketData);
var response = await client.CreateOrderDraftFromBasketDataAsync(command);
_logger.LogDebug(" grpc response: {@response}", response);
var client = GrpcClient.Create<OrderingGrpc.OrderingGrpcClient>(httpClient);
_logger.LogDebug(" grpc client created, basketData={@basketData}", basketData);
try
{
var command = MapToOrderDraftCommand(basketData);
var response = await client.CreateOrderDraftFromBasketDataAsync(command);
_logger.LogDebug(" grpc response: {@response}", response);
return MapToResponse(response);
}
catch (RpcException e)
{
_logger.LogError($"Error calling via grpc to ordering: {e.Status} - {e.Message}");
}
}
}
return null;
return MapToResponse(response, basketData);
});
}
private OrderData MapToResponse(GrpcOrdering.OrderDraftDTO orderDraft)
private OrderData MapToResponse(GrpcOrdering.OrderDraftDTO orderDraft, BasketData basketData)
{
if (orderDraft == null)
{
@ -72,6 +48,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
var data = new OrderData
{
Buyer = basketData.BuyerId,
Total = (decimal)orderDraft.Total,
};


+ 0
- 5
src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.json View File

@ -1,9 +1,4 @@
{
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
}
},
"Logging": {
"IncludeScopes": false,
"Debug": {


+ 1
- 0
src/ApiGateways/Mobile.Bff.Shopping/aggregator/appsettings.localhost.json View File

@ -5,6 +5,7 @@
"orders": "http://localhost:55102",
"identity": "http://localhost:55105",
"grpcBasket": "http://localhost:5580",
"grpcCatalog": "http://localhost:81",
"grpcOrdering": "http://localhost:5581"
},
"IdentityUrlExternal": "http://localhost:5105",


+ 6
- 6
src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs View File

@ -39,8 +39,6 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers
}
// Retrieve the current basket
Log.Information("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ GetByIdAsync @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
var basket = await _basket.GetById(data.BuyerId) ?? new BasketData(data.BuyerId);
Log.Debug("get basket by id response={@response}", basket);
@ -127,12 +125,14 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers
var currentBasket = (await _basket.GetById(data.BasketId)) ?? new BasketData(data.BasketId);
// 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()
{
@ -144,7 +144,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Controllers
Id = Guid.NewGuid().ToString()
});
}
// Step 5: Update basket
await _basket.UpdateAsync(currentBasket);


+ 49
- 61
src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs View File

@ -2,76 +2,52 @@
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System.Net.Http;
using System.Threading.Tasks;
using Grpc.Net.Client;
using System;
using System.Linq;
using GrpcBasket;
using Grpc.Core;
using System.Net.Http;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
{
public class BasketService : IBasketService
{
private readonly HttpClient _httpClient;
private readonly UrlsConfig _urls;
public readonly HttpClient _httpClient;
private readonly ILogger<BasketService> _logger;
public BasketService(HttpClient httpClient, IOptions<UrlsConfig> config, ILogger<BasketService> logger)
{
_httpClient = httpClient;
_urls = config.Value;
_httpClient = httpClient;
_logger = logger;
}
public async Task<BasketData> GetById(string id)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using (var httpClientHandler = new HttpClientHandler())
return await GrpcCallerService.CallService(_urls.GrpcBasket, async httpClient =>
{
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };
using (var httpClient = new HttpClient(httpClientHandler))
{
//httpClient.BaseAddress = new Uri("http://10.0.75.1:5580");
httpClient.BaseAddress = new Uri(_urls.GrpcBasket);
_logger.LogDebug("Creating grpc client for basket {@httpClient.BaseAddress} ", httpClient.BaseAddress);
var client = GrpcClient.Create<Basket.BasketClient>(httpClient);
_logger.LogDebug("grpc client created, request = {@id}", id);
try
{
var response = await client.GetBasketByIdAsync(new BasketRequest { Id = id });
var client = GrpcClient.Create<Basket.BasketClient>(httpClient);
_logger.LogDebug("grpc client created, request = {@id}", id);
var response = await client.GetBasketByIdAsync(new BasketRequest { Id = id });
_logger.LogDebug("grpc response {@response}", response);
_logger.LogDebug("grpc response {@response}", response);
return MapToBasketData(response);
}
catch (RpcException e)
{
_logger.LogError($"Error calling via grpc: {e.Status} - {e.Message}");
}
}
}
return null;
return MapToBasketData(response);
});
}
public async Task UpdateAsync(BasketData currentBasket)
{
_httpClient.BaseAddress = new Uri(_urls.Basket + UrlsConfig.BasketOperations.UpdateBasket());
var client = GrpcClient.Create<Basket.BasketClient>(_httpClient);
var request = MapToCustomerBasketRequest(currentBasket);
await GrpcCallerService.CallService(_urls.GrpcBasket, async httpClient =>
{
var client = GrpcClient.Create<Basket.BasketClient>(httpClient);
_logger.LogDebug("Grpc update basket currentBasket {@currentBasket}", currentBasket);
var request = MapToCustomerBasketRequest(currentBasket);
_logger.LogDebug("Grpc update basket request {@request}", request);
await client.UpdateBasketAsync(request);
return await client.UpdateBasketAsync(request);
});
}
private BasketData MapToBasketData(CustomerBasketResponse customerBasketRequest)
@ -86,16 +62,22 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
BuyerId = customerBasketRequest.Buyerid
};
customerBasketRequest.Items.ToList().ForEach(item => map.Items.Add(new BasketDataItem
customerBasketRequest.Items.ToList().ForEach(item =>
{
Id = item.Id,
OldUnitPrice = (decimal)item.Oldunitprice,
PictureUrl = item.Pictureurl,
ProductId = item.Productid,
ProductName = item.Productname,
Quantity = item.Quantity,
UnitPrice = (decimal)item.Unitprice
}));
if (item.Id != null)
{
map.Items.Add(new BasketDataItem
{
Id = item.Id,
OldUnitPrice = (decimal)item.Oldunitprice,
PictureUrl = item.Pictureurl,
ProductId = item.Productid,
ProductName = item.Productname,
Quantity = item.Quantity,
UnitPrice = (decimal)item.Unitprice
});
}
});
return map;
}
@ -112,16 +94,22 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
Buyerid = basketData.BuyerId
};
basketData.Items.ToList().ForEach(item => map.Items.Add(new BasketItemResponse
basketData.Items.ToList().ForEach(item =>
{
Id = item.Id,
Oldunitprice = (double)item.OldUnitPrice,
Pictureurl = item.PictureUrl,
Productid = item.ProductId,
Productname = item.ProductName,
Quantity = item.Quantity,
Unitprice = (double)item.UnitPrice
}));
if (item.Id != null)
{
map.Items.Add(new BasketItemResponse
{
Id = item.Id,
Oldunitprice = (double)item.OldUnitPrice,
Pictureurl = item.PictureUrl,
Productid = item.ProductId,
Productname = item.ProductName,
Quantity = item.Quantity,
Unitprice = (double)item.UnitPrice
});
}
});
return map;
}


+ 18
- 18
src/ApiGateways/Web.Bff.Shopping/aggregator/Services/CatalogService.cs View File

@ -2,7 +2,6 @@
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
@ -29,27 +28,28 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
public async Task<CatalogItem> GetCatalogItemAsync(int id)
{
_httpClient.BaseAddress = new Uri(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemById(id));
var client = GrpcClient.Create<CatalogClient>(_httpClient);
var request = new CatalogItemRequest { Id = id };
var response = await client.GetItemByIdAsync(request);
return MapToCatalogItemResponse(response);
return await GrpcCallerService.CallService(_urls.GrpcCatalog, async httpClient =>
{
var client = GrpcClient.Create<CatalogClient>(httpClient);
var request = new CatalogItemRequest { Id = id };
_logger.LogInformation("grpc client created, request = {@request}", request);
var response = await client.GetItemByIdAsync(request);
_logger.LogInformation("grpc response {@response}", response);
return MapToCatalogItemResponse(response);
});
}
public async Task<IEnumerable<CatalogItem>> GetCatalogItemsAsync(IEnumerable<int> ids)
{
_httpClient.BaseAddress = new Uri(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemsById(ids));
var client = GrpcClient.Create<CatalogClient>(_httpClient);
var request = new CatalogItemsRequest { Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10 };
var response = await client.GetItemsByIdsAsync(request);
return response.Data.Select(this.MapToCatalogItemResponse);
//var stringContent = await _httpClient.GetStringAsync(_urls.Catalog + UrlsConfig.CatalogOperations.GetItemsById(ids));
//var catalogItems = JsonConvert.DeserializeObject<CatalogItem[]>(stringContent);
//return catalogItems;
return await GrpcCallerService.CallService(_urls.GrpcCatalog, async httpClient =>
{
var client = GrpcClient.Create<CatalogClient>(httpClient);
var request = new CatalogItemsRequest { Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10 };
_logger.LogInformation("grpc client created, request = {@request}", request);
var response = await client.GetItemsByIdsAsync(request);
_logger.LogInformation("grpc response {@response}", response);
return response.Data.Select(this.MapToCatalogItemResponse);
});
}
private CatalogItem MapToCatalogItemResponse(CatalogItemResponse catalogItemResponse)


+ 73
- 0
src/ApiGateways/Web.Bff.Shopping/aggregator/Services/GrpcCallerService.cs View File

@ -0,0 +1,73 @@
using System.Net.Http;
using System.Threading.Tasks;
using System;
using Grpc.Core;
using Serilog;
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
{
public static class GrpcCallerService
{
public static async Task<TResponse> CallService<TResponse>(string urlGrpc, Func<HttpClient, Task<TResponse>> func)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
};
using var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(urlGrpc)
};
Log.Information("Creating grpc client base address urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress} ", urlGrpc, httpClient.BaseAddress);
try
{
return await func(httpClient);
}
catch (RpcException e)
{
Log.Error($"Error calling via grpc: {e.Status} - {e.Message}");
}
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
return default;
}
public static async Task CallService(string urlGrpc, Func<HttpClient, Task> func)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }
};
using var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(urlGrpc)
};
Log.Debug("Creating grpc client base address {@httpClient.BaseAddress} ", httpClient.BaseAddress);
try
{
await func(httpClient);
}
catch (RpcException e)
{
Log.Error($"Error calling via grpc: {e.Status} - {e.Message}");
}
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", false);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", false);
}
}
}

+ 10
- 32
src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderingService.cs View File

@ -14,52 +14,30 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
{
public class OrderingService : IOrderingService
{
private readonly HttpClient _httpClient;
private readonly UrlsConfig _urls;
private readonly ILogger<OrderingService> _logger;
public readonly HttpClient _httpClient;
public OrderingService(HttpClient httpClient, IOptions<UrlsConfig> config, ILogger<OrderingService> logger)
{
_httpClient = httpClient;
_urls = config.Value;
_httpClient = httpClient;
_logger = logger;
}
public async Task<OrderData> GetOrderDraftAsync(BasketData basketData)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2Support", true);
using (var httpClientHandler = new HttpClientHandler())
return await GrpcCallerService.CallService(_urls.GrpcOrdering, async httpClient =>
{
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; };
using (var httpClient = new HttpClient(httpClientHandler))
{
httpClient.BaseAddress = new Uri(_urls.GrpcOrdering);
_logger.LogDebug(" Creating grpc client for ordering {@httpClient.BaseAddress}", httpClient.BaseAddress);
var client = GrpcClient.Create<OrderingGrpc.OrderingGrpcClient>(httpClient);
var client = GrpcClient.Create<OrderingGrpc.OrderingGrpcClient>(httpClient);
_logger.LogDebug(" grpc client created, basketData={@basketData}", basketData);
_logger.LogDebug(" grpc client created, basketData={@basketData}", basketData);
try
{
var command = MapToOrderDraftCommand(basketData);
var response = await client.CreateOrderDraftFromBasketDataAsync(command);
_logger.LogDebug(" grpc response: {@response}", response);
return MapToResponse(response, basketData);
}
catch (RpcException e)
{
_logger.LogError($"Error calling via grpc to ordering: {e.Status} - {e.Message}");
}
}
}
var command = MapToOrderDraftCommand(basketData);
var response = await client.CreateOrderDraftFromBasketDataAsync(command);
_logger.LogDebug(" grpc response: {@response}", response);
return null;
return MapToResponse(response, basketData);
});
}
private OrderData MapToResponse(GrpcOrdering.OrderDraftDTO orderDraft, BasketData basketData)


+ 2
- 2
src/ApiGateways/Web.Bff.Shopping/aggregator/Startup.cs View File

@ -144,9 +144,9 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "Shopping Aggregator for Mobile Clients",
Title = "Shopping Aggregator for Web Clients",
Version = "v1",
Description = "Shopping Aggregator for Mobile Clients"
Description = "Shopping Aggregator for Web Clients"
});
options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme


+ 0
- 10
src/Services/Basket/Basket.API/Controllers/BasketController.cs 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)


+ 0
- 2
src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs View File

@ -26,8 +26,6 @@ namespace Basket.API.IntegrationEvents.EventHandling
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
await _repository.DeleteBasketAsync(@event.UserId.ToString());
}
}


+ 0
- 4
src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs View File

@ -26,8 +26,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var userIds = _repository.GetUsers();
foreach (var id in userIds)
@ -46,8 +44,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even
if (itemsToUpdate != null)
{
_logger.LogInformation("----- ProductPriceChangedIntegrationEventHandler - Updating items in basket for user: {BuyerId} ({@Items})", basket.BuyerId, itemsToUpdate);
foreach (var item in itemsToUpdate)
{
if (item.UnitPrice == oldPrice)


+ 1
- 2
src/Services/Basket/Basket.API/Model/CustomerBasket.cs 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>();
}
}
}

+ 31
- 21
src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs View File

@ -116,29 +116,39 @@ namespace Catalog.API.Grpc
PageSize = pageSize,
};
items.ForEach(i => result.Data.Add(new CatalogItemResponse()
items.ForEach(i =>
{
AvailableStock = i.AvailableStock,
Description = i.Description,
Id = i.Id,
MaxStockThreshold = i.MaxStockThreshold,
Name = i.Name,
OnReorder = i.OnReorder,
PictureFileName = i.PictureFileName,
PictureUri = i.PictureUri,
RestockThreshold = i.RestockThreshold,
CatalogBrand = new CatalogApi.CatalogBrand()
var brand = i.CatalogBrand == null
? null
: new CatalogApi.CatalogBrand()
{
Id = i.CatalogBrand.Id,
Name = i.CatalogBrand.Brand,
};
var catalogType = i.CatalogType == null
? null
: new CatalogApi.CatalogType()
{
Id = i.CatalogType.Id,
Type = i.CatalogType.Type,
};
result.Data.Add(new CatalogItemResponse()
{
Id = i.CatalogBrand.Id,
Name = i.CatalogBrand.Brand,
},
CatalogType = new CatalogApi.CatalogType()
{
Id = i.CatalogType.Id,
Type = i.CatalogType.Type,
},
Price = (double)i.Price,
}));
AvailableStock = i.AvailableStock,
Description = i.Description,
Id = i.Id,
MaxStockThreshold = i.MaxStockThreshold,
Name = i.Name,
OnReorder = i.OnReorder,
PictureFileName = i.PictureFileName,
PictureUri = i.PictureUri,
RestockThreshold = i.RestockThreshold,
CatalogBrand = brand,
CatalogType = catalogType,
Price = (double)i.Price,
});
});
return result;
}


+ 0
- 4
src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs View File

@ -39,8 +39,6 @@ namespace Catalog.API.IntegrationEvents
{
try
{
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId_published} from {AppName} - ({@IntegrationEvent})", evt.Id, Program.AppName, evt);
await _eventLogService.MarkEventAsInProgressAsync(evt.Id);
_eventBus.Publish(evt);
await _eventLogService.MarkEventAsPublishedAsync(evt.Id);
@ -54,8 +52,6 @@ namespace Catalog.API.IntegrationEvents
public async Task SaveEventAndCatalogContextChangesAsync(IntegrationEvent evt)
{
_logger.LogInformation("----- CatalogIntegrationEventService - Saving changes and integrationEvent: {IntegrationEventId}", evt.Id);
//Use of an EF Core resiliency strategy when using multiple DbContexts within an explicit BeginTransaction():
//See: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
await ResilientTransaction.New(_catalogContext).ExecuteAsync(async () =>


+ 0
- 2
src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs View File

@ -32,8 +32,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var confirmedOrderStockItems = new List<ConfirmedOrderStockItem>();
foreach (var orderStockItem in @event.OrderStockItems)


+ 0
- 2
src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs View File

@ -25,8 +25,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
//we're not blocking stock/inventory
foreach (var orderStockItem in @event.OrderStockItems)
{


+ 1
- 7
src/Services/Catalog/Catalog.API/Proto/catalog.proto View File

@ -56,11 +56,5 @@ service Catalog {
};
<< */
}
rpc GetItemsByIds (CatalogItemsRequest) returns (PaginatedItemsResponse) {
/* >>
option (google.api.http) = {
get: "/api/v1/catalog/items/ids/{ids}"
};
<< */
}
rpc GetItemsByIds (CatalogItemsRequest) returns (PaginatedItemsResponse) {}
}

+ 0
- 3
src/Services/Location/Locations.API/Infrastructure/Services/LocationsService.cs View File

@ -72,9 +72,6 @@
{
var newUserLocations = MapUserLocationDetails(newLocations);
var @event = new UserLocationUpdatedIntegrationEvent(userId, newUserLocations);
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
_eventBus.Publish(@event);
}


+ 0
- 2
src/Services/Marketing/Marketing.API/IntegrationEvents/Handlers/UserLocationUpdatedIntegrationEventHandler.cs View File

@ -28,8 +28,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var userMarketingData = await _marketingDataRepository.GetAsync(@event.UserId);
userMarketingData = userMarketingData ??
new MarketingData() { UserId = @event.UserId };


+ 0
- 2
src/Services/Ordering/Ordering.API/Application/Behaviors/ValidatorBehavior.cs View File

@ -24,8 +24,6 @@ namespace Ordering.API.Application.Behaviors
{
var typeName = request.GetGenericTypeName();
_logger.LogInformation("----- Validating command {CommandType}", typeName);
var failures = _validators
.Select(v => v.Validate(request))
.SelectMany(result => result.Errors)


+ 0
- 2
src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs View File

@ -53,8 +53,6 @@
order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units);
}
_logger.LogInformation("----- Creating Order - Order: {@Order}", order);
_orderRepository.Add(order);
return await _orderRepository.UnitOfWork


+ 0
- 1
src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs View File

@ -27,7 +27,6 @@ namespace Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVeri
public async Task Handle(BuyerAndPaymentMethodVerifiedDomainEvent buyerPaymentMethodVerifiedEvent, CancellationToken cancellationToken)
{
var log = _logger.CreateLogger<UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler>();
log.LogInformation("----- Handling BuyerAndPaymentMethodVerifiedDomainEvent - buyerPaymentMethodVerifiedEvent: {@buyerPaymentMethodVerifiedEvent}", buyerPaymentMethodVerifiedEvent);
var orderToUpdate = await _orderRepository.GetAsync(buyerPaymentMethodVerifiedEvent.OrderId);
orderToUpdate.SetBuyerId(buyerPaymentMethodVerifiedEvent.Buyer.Id);
orderToUpdate.SetPaymentId(buyerPaymentMethodVerifiedEvent.Payment.Id);


+ 7
- 8
src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
{
public class ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler
public class ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler
: INotificationHandler<OrderStartedDomainEvent>
{
private readonly ILoggerFactory _logger;
@ -21,8 +21,8 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
private readonly IOrderingIntegrationEventService _orderingIntegrationEventService;
public ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler(
ILoggerFactory logger,
IBuyerRepository buyerRepository,
ILoggerFactory logger,
IBuyerRepository buyerRepository,
IIdentityService identityService,
IOrderingIntegrationEventService orderingIntegrationEventService)
{
@ -33,13 +33,13 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
}
public async Task Handle(OrderStartedDomainEvent orderStartedEvent, CancellationToken cancellationToken)
{
{
var cardTypeId = (orderStartedEvent.CardTypeId != 0) ? orderStartedEvent.CardTypeId : 1;
var buyer = await _buyerRepository.FindAsync(orderStartedEvent.UserId);
bool buyerOriginallyExisted = (buyer == null) ? false : true;
if (!buyerOriginallyExisted)
{
{
buyer = new Buyer(orderStartedEvent.UserId, orderStartedEvent.UserName);
}
@ -51,8 +51,8 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
orderStartedEvent.CardExpiration,
orderStartedEvent.Order.Id);
var buyerUpdated = buyerOriginallyExisted ?
_buyerRepository.Update(buyer) :
var buyerUpdated = buyerOriginallyExisted ?
_buyerRepository.Update(buyer) :
_buyerRepository.Add(buyer);
await _buyerRepository.UnitOfWork
@ -60,7 +60,6 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
var orderStatusChangedTosubmittedIntegrationEvent = new OrderStatusChangedToSubmittedIntegrationEvent(orderStartedEvent.Order.Id, orderStartedEvent.Order.OrderStatus.Name, buyer.Name);
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedTosubmittedIntegrationEvent);
_logger.CreateLogger<ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler>()
.LogTrace("Buyer {BuyerId} and related payment method were validated or updated for orderId: {OrderId}.",
buyerUpdated.Id, orderStartedEvent.Order.Id);


+ 0
- 2
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs View File

@ -37,8 +37,6 @@ namespace Ordering.API.Application.IntegrationEvents.EventHandling
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var command = new SetAwaitingValidationOrderStatusCommand(@event.OrderId);
_logger.LogInformation(


+ 0
- 2
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs View File

@ -31,8 +31,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var command = new CancelOrderCommand(@event.OrderId);
_logger.LogInformation(


+ 0
- 2
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSuccededIntegrationEventHandler.cs View File

@ -31,8 +31,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var command = new SetPaidOrderStatusCommand(@event.OrderId);
_logger.LogInformation(


+ 0
- 2
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs View File

@ -31,8 +31,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var command = new SetStockConfirmedOrderStatusCommand(@event.OrderId);
_logger.LogInformation(


+ 0
- 2
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs View File

@ -30,8 +30,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var orderStockRejectedItems = @event.OrderStockItems
.FindAll(c => !c.HasStock)
.Select(c => c.ProductId)


+ 2
- 8
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs View File

@ -35,11 +35,9 @@ namespace Ordering.API.Application.IntegrationEvents.EventHandling
/// </param>
/// <returns></returns>
public async Task Handle(UserCheckoutAcceptedIntegrationEvent @event)
{
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
var result = false;
if (@event.RequestId != Guid.Empty)
@ -62,11 +60,7 @@ namespace Ordering.API.Application.IntegrationEvents.EventHandling
result = await _mediator.Send(requestCreateOrder);
if (result)
{
_logger.LogInformation("----- CreateOrderCommand suceeded - RequestId: {RequestId}", @event.RequestId);
}
else
if (!result)
{
_logger.LogWarning("CreateOrderCommand failed - RequestId: {RequestId}", @event.RequestId);
}


+ 0
- 4
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs View File

@ -45,8 +45,6 @@ namespace Ordering.API.Application.IntegrationEvents
foreach (var logEvt in pendingLogEvents)
{
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", logEvt.EventId, Program.AppName, logEvt.IntegrationEvent);
try
{
await _eventLogService.MarkEventAsInProgressAsync(logEvt.EventId);
@ -64,8 +62,6 @@ namespace Ordering.API.Application.IntegrationEvents
public async Task AddAndSaveEventAsync(IntegrationEvent evt)
{
_logger.LogInformation("----- Enqueuing integration event {IntegrationEventId} to repository ({@IntegrationEvent})", evt.Id, evt);
await _eventLogService.SaveEventAsync(evt, _orderingContext.GetCurrentTransaction());
}
}


+ 3
- 3
src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs View File

@ -49,7 +49,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers
{
var requestCancelOrder = new IdentifiedCommand<CancelOrderCommand, bool>(command, guid);
_logger.LogInformation(
_logger.LogTrace(
"----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
requestCancelOrder.GetGenericTypeName(),
nameof(requestCancelOrder.Command.OrderNumber),
@ -79,7 +79,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers
{
var requestShipOrder = new IdentifiedCommand<ShipOrderCommand, bool>(command, guid);
_logger.LogInformation(
_logger.LogTrace(
"----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
requestShipOrder.GetGenericTypeName(),
nameof(requestShipOrder.Command.OrderNumber),
@ -141,7 +141,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers
[HttpPost]
public async Task<ActionResult<OrderDraftDTO>> CreateOrderDraftFromBasketDataAsync([FromBody] CreateOrderDraftCommand createOrderDraftCommand)
{
_logger.LogInformation(
_logger.LogTrace(
"----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
createOrderDraftCommand.GetGenericTypeName(),
nameof(createOrderDraftCommand.BuyerId),


+ 1
- 1
src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs View File

@ -27,7 +27,7 @@ namespace GrpcOrdering
public override async Task<OrderDraftDTO> CreateOrderDraftFromBasketData(CreateOrderDraftCommand createOrderDraftCommand, ServerCallContext context)
{
_logger.LogInformation($"Begin grpc call from method {context.Method} for ordering get order draft {createOrderDraftCommand}");
_logger.LogInformation(
_logger.LogTrace(
"----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
createOrderDraftCommand.GetGenericTypeName(),
nameof(createOrderDraftCommand.BuyerId),


+ 7
- 6
src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile View File

@ -7,14 +7,15 @@ WORKDIR /src
COPY scripts scripts/
COPY src/ApiGateways/*/*.csproj /src/csproj-files/
COPY src/ApiGateways/*/*/*.csproj /src/csproj-files/
COPY src/BuildingBlocks/*/*/*.csproj /src/csproj-files/
COPY src/Services/*/*/*.csproj /src/csproj-files/
COPY src/Web/*/*.csproj /src/csproj-files/
COPY ApiGateways/*/*.csproj csproj-files/
COPY ApiGateways/*/*/*.csproj csproj-files/
COPY BuildingBlocks/*/*/*.csproj csproj-files/
COPY Services/*/*/*.csproj csproj-files/
COPY Web/*/*.csproj csproj-files/
COPY . .
WORKDIR /src/src/Services/Ordering/Ordering.BackgroundTasks
WORKDIR /src/Services/Ordering/Ordering.BackgroundTasks
RUN dotnet publish -c Release -o /app
FROM build AS publish


+ 0
- 2
src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs View File

@ -55,8 +55,6 @@ namespace Ordering.BackgroundTasks.Tasks
{
var confirmGracePeriodEvent = new GracePeriodConfirmedIntegrationEvent(orderId);
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", confirmGracePeriodEvent.Id, _settings.SubscriptionClientName, confirmGracePeriodEvent);
_eventBus.Publish(confirmGracePeriodEvent);
}
}


+ 4
- 3
src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs View File

@ -18,7 +18,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
// Address is a Value Object pattern example persisted as EF Core 2.0 owned entity
public Address Address { get; private set; }
public int? GetBuyerId => _buyerId;
public int? GetBuyerId { get { return this._buyerId; } }
private int? _buyerId;
public OrderStatus OrderStatus { get; private set; }
@ -26,7 +26,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
private string _description;
// Draft orders have this set to true. Currently we don't check anywhere the draft status of an Order, but we could do it if needed
private bool _isDraft;
@ -46,7 +46,8 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
return order;
}
protected Order() {
protected Order()
{
_orderItems = new List<OrderItem>();
_isDraft = false;
}


+ 31
- 7
src/Services/Ordering/Ordering.Infrastructure/EntityConfigurations/OrderEntityTypeConfiguration.cs View File

@ -27,10 +27,31 @@ namespace Ordering.Infrastructure.EntityConfigurations
a.WithOwner();
});
orderConfiguration.Property<DateTime>("OrderDate").IsRequired();
orderConfiguration.Property<int?>("BuyerId").IsRequired(false);
orderConfiguration.Property<int>("OrderStatusId").IsRequired();
orderConfiguration.Property<int?>("PaymentMethodId").IsRequired(false);
orderConfiguration
.Property<int?>("_buyerId")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("BuyerId")
.IsRequired(false);
orderConfiguration
.Property<DateTime>("_orderDate")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("OrderDate")
.IsRequired();
orderConfiguration
.Property<int>("_orderStatusId")
// .HasField("_orderStatusId")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("OrderStatusId")
.IsRequired();
orderConfiguration
.Property<int?>("_paymentMethodId")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("PaymentMethodId")
.IsRequired(false);
orderConfiguration.Property<string>("Description").IsRequired(false);
var navigation = orderConfiguration.Metadata.FindNavigation(nameof(Order.OrderItems));
@ -41,18 +62,21 @@ namespace Ordering.Infrastructure.EntityConfigurations
orderConfiguration.HasOne<PaymentMethod>()
.WithMany()
.HasForeignKey("PaymentMethodId")
// .HasForeignKey("PaymentMethodId")
.HasForeignKey("_paymentMethodId")
.IsRequired(false)
.OnDelete(DeleteBehavior.Restrict);
orderConfiguration.HasOne<Buyer>()
.WithMany()
.IsRequired(false)
.HasForeignKey("BuyerId");
// .HasForeignKey("BuyerId");
.HasForeignKey("_buyerId");
orderConfiguration.HasOne(o => o.OrderStatus)
.WithMany()
.HasForeignKey("OrderStatusId");
// .HasForeignKey("OrderStatusId");
.HasForeignKey("_orderStatusId");
}
}
}

+ 20
- 5
src/Services/Ordering/Ordering.Infrastructure/EntityConfigurations/OrderItemEntityTypeConfiguration.cs View File

@ -22,22 +22,37 @@ namespace Ordering.Infrastructure.EntityConfigurations
orderItemConfiguration.Property<int>("OrderId")
.IsRequired();
orderItemConfiguration.Property<decimal>("Discount")
orderItemConfiguration
.Property<decimal>("_discount")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("Discount")
.IsRequired();
orderItemConfiguration.Property<int>("ProductId")
.IsRequired();
orderItemConfiguration.Property<string>("ProductName")
orderItemConfiguration
.Property<string>("_productName")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("ProductName")
.IsRequired();
orderItemConfiguration.Property<decimal>("UnitPrice")
orderItemConfiguration
.Property<decimal>("_unitPrice")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("UnitPrice")
.IsRequired();
orderItemConfiguration.Property<int>("Units")
orderItemConfiguration
.Property<int>("_units")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("Units")
.IsRequired();
orderItemConfiguration.Property<string>("PictureUrl")
orderItemConfiguration
.Property<string>("_pictureUrl")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("PictureUrl")
.IsRequired(false);
}
}


+ 22
- 6
src/Services/Ordering/Ordering.Infrastructure/EntityConfigurations/PaymentMethodEntityTypeConfiguration.cs View File

@ -23,27 +23,43 @@ namespace Ordering.Infrastructure.EntityConfigurations
paymentConfiguration.Property<int>("BuyerId")
.IsRequired();
paymentConfiguration.Property<string>("CardHolderName")
paymentConfiguration
.Property<string>("_cardHolderName")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("CardHolderName")
.HasMaxLength(200)
.IsRequired();
paymentConfiguration.Property<string>("Alias")
paymentConfiguration
.Property<string>("_alias")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("Alias")
.HasMaxLength(200)
.IsRequired();
paymentConfiguration.Property<string>("CardNumber")
paymentConfiguration
.Property<string>("_cardNumber")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("CardNumber")
.HasMaxLength(25)
.IsRequired();
paymentConfiguration.Property<DateTime>("Expiration")
paymentConfiguration
.Property<DateTime>("_expiration")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("Expiration")
.HasMaxLength(25)
.IsRequired();
paymentConfiguration.Property<int>("CardTypeId")
paymentConfiguration
.Property<int>("_cardTypeId")
.UsePropertyAccessMode(PropertyAccessMode.Field)
.HasColumnName("CardTypeId")
.IsRequired();
paymentConfiguration.HasOne(p => p.CardType)
.WithMany()
.HasForeignKey("CardTypeId");
.HasForeignKey("_cardTypeId");
}
}
}

+ 9
- 1
src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs View File

@ -3,6 +3,7 @@ using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using Ordering.Domain.Exceptions;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories
@ -28,7 +29,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositor
public Order Add(Order order)
{
return _context.Orders.Add(order).Entity;
}
public async Task<Order> GetAsync(int orderId)
@ -37,6 +38,13 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositor
.Orders
.Include(x => x.Address)
.FirstOrDefaultAsync(o => o.Id == orderId);
if (order == null)
{
order = _context
.Orders
.Local
.FirstOrDefault(o => o.Id == orderId);
}
if (order != null)
{
await _context.Entry(order)


+ 6
- 6
src/Services/Ordering/Ordering.SignalrHub/Dockerfile View File

@ -7,14 +7,14 @@ WORKDIR /src
COPY scripts scripts/
COPY src/ApiGateways/*/*.csproj /src/csproj-files/
COPY src/ApiGateways/*/*/*.csproj /src/csproj-files/
COPY src/BuildingBlocks/*/*/*.csproj /src/csproj-files/
COPY src/Services/*/*/*.csproj /src/csproj-files/
COPY src/Web/*/*.csproj /src/csproj-files/
COPY ApiGateways/*/*.csproj csproj-files/
COPY ApiGateways/*/*/*.csproj csproj-files/
COPY BuildingBlocks/*/*/*.csproj csproj-files/
COPY Services/*/*/*.csproj csproj-files/
COPY Web/*/*.csproj csproj-files/
COPY . .
WORKDIR /src/src/Services/Ordering/Ordering.SignalrHub
WORKDIR /src/Services/Ordering/Ordering.SignalrHub
RUN dotnet publish -c Release -o /app
FROM build AS publish


+ 0
- 2
src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs View File

@ -27,8 +27,6 @@ namespace Ordering.SignalrHub.IntegrationEvents
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });


+ 0
- 2
src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs View File

@ -28,8 +28,6 @@ namespace Ordering.SignalrHub.IntegrationEvents.EventHandling
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });


+ 0
- 2
src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs View File

@ -26,8 +26,6 @@ namespace Ordering.SignalrHub.IntegrationEvents.EventHandling
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });


+ 0
- 2
src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs View File

@ -28,8 +28,6 @@ namespace Ordering.SignalrHub.IntegrationEvents.EventHandling
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });


+ 0
- 2
src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs View File

@ -29,8 +29,6 @@ namespace Ordering.SignalrHub.IntegrationEvents.EventHandling
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });


+ 0
- 2
src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs View File

@ -29,8 +29,6 @@ namespace Ordering.SignalrHub.IntegrationEvents.EventHandling
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
await _hubContext.Clients
.Group(@event.BuyerName)
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });


+ 0
- 4
src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs View File

@ -31,8 +31,6 @@
{
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
{
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
IntegrationEvent orderPaymentIntegrationEvent;
//Business feature comment:
@ -50,8 +48,6 @@
orderPaymentIntegrationEvent = new OrderPaymentFailedIntegrationEvent(@event.OrderId);
}
_logger.LogInformation("----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", orderPaymentIntegrationEvent.Id, Program.AppName, orderPaymentIntegrationEvent);
_eventBus.Publish(orderPaymentIntegrationEvent);
await Task.CompletedTask;


+ 0
- 2
src/Web/WebMVC/Controllers/AccountController.cs View File

@ -25,8 +25,6 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
var user = User as ClaimsPrincipal;
var token = await HttpContext.GetTokenAsync("access_token");
_logger.LogInformation("----- User {@User} authenticated into {AppName}", user, Program.AppName);
if (token != null)
{
ViewData["access_token"] = token;


+ 2
- 2
src/Web/WebMVC/Controllers/CartController.cs View File

@ -41,7 +41,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
return View();
}
[HttpPost]
public async Task<IActionResult> Index(Dictionary<string, int> quantities, string action)
{
@ -72,7 +72,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
var user = _appUserParser.Parse(HttpContext.User);
await _basketSvc.AddItemToBasket(user, productDetails.Id);
}
return RedirectToAction("Index", "Catalog");
return RedirectToAction("Index", "Catalog");
}
catch (BrokenCircuitException)
{


+ 1
- 0
src/docker-compose.override.yml View File

@ -288,6 +288,7 @@ services:
- urls__orders=http://ordering-api
- urls__identity=http://identity-api
- urls__grpcBasket=http://10.0.75.1:5580
- urls__grpcCatalog=http://10.0.75.1:9101
- urls__grpcOrdering=http://10.0.75.1:5581
- CatalogUrlHC=http://catalog-api/hc
- OrderingUrlHC=http://ordering-api/hc


Loading…
Cancel
Save