Browse Source

Fixed issue #291ordering.api fails after submitting orders

pull/296/head
Ramón Tomás 7 years ago
parent
commit
8dc176add9
4 changed files with 13 additions and 9 deletions
  1. +7
    -0
      src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs
  2. +2
    -7
      src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs
  3. +1
    -1
      src/Services/Ordering/Ordering.API/Ordering.API.csproj
  4. +3
    -1
      src/Services/Ordering/Ordering.API/Startup.cs

+ 7
- 0
src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs View File

@ -1,9 +1,12 @@
using Autofac;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories;
using System.Reflection;
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules
{
@ -38,6 +41,10 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Autof
builder.RegisterType<RequestManager>()
.As<IRequestManager>()
.InstancePerLifetimeScope();
builder.RegisterAssemblyTypes(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly)
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
}
}
}

+ 2
- 7
src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs View File

@ -21,16 +21,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Autof
// Register all the Command classes (they implement IAsyncRequestHandler) in assembly holding the Commands
builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly)
.As(o => o.GetInterfaces()
.Where(i => i.IsClosedTypeOf(typeof(IAsyncRequestHandler<,>)))
.Select(i => new KeyedService("IAsyncRequestHandler", i)));
.AsClosedTypesOf(typeof(IAsyncRequestHandler<,>));
// Register all the event classes (they implement IAsyncNotificationHandler) in assembly holding the Commands
builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly)
.As(o => o.GetInterfaces()
.Where(i => i.IsClosedTypeOf(typeof(IAsyncNotificationHandler<>)))
.Select(i => new KeyedService("IAsyncNotificationHandler", i)))
.AsImplementedInterfaces();
.AsClosedTypesOf(typeof(IAsyncNotificationHandler<>));
builder


+ 1
- 1
src/Services/Ordering/Ordering.API/Ordering.API.csproj View File

@ -34,7 +34,7 @@
<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="7.0.3" />
<PackageReference Include="FluentValidation.MVC6" Version="6.4.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="2.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.0" />


+ 3
- 1
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -67,11 +67,13 @@
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
}).AddControllersAsServices(); //Injecting Controllers themselves thru DI
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
// Configure GracePeriodManager Hosted Service
services.AddSingleton<IHostedService, GracePeriodManagerService>();
services.Configure<GracePeriodManagerSettings>(Configuration);
services.AddTransient<IOrderingIntegrationEventService, OrderingIntegrationEventService>();
services.AddHealthChecks(checks =>
{
var minutes = 1;


Loading…
Cancel
Save