Revert "updates on top of gababus changes for basket signalR"
This reverts commit fe5863b52bee211541d9698c32e45ed88ff6f6b9.
This commit is contained in:
parent
fe5863b52b
commit
8acd15e05b
@ -1,5 +1,4 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Basket.SignalrHub.IntegrationEvents;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -25,8 +24,6 @@ namespace Basket.SignalrHub.AutofacModules
|
|||||||
|
|
||||||
// builder.RegisterAssemblyTypes(typeof(NewIntegrationEvent).GetTypeInfo().Assembly)
|
// builder.RegisterAssemblyTypes(typeof(NewIntegrationEvent).GetTypeInfo().Assembly)
|
||||||
// .AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
|
// .AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
|
||||||
builder.RegisterAssemblyTypes(typeof(UserAddedCartItemToBasketIntegrationEvent).GetTypeInfo().Assembly)
|
|
||||||
.AsClosedTypesOf(typeof(IIntegrationEventHandler<>));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="IntegrationEvents\EventHandling\" />
|
||||||
|
<Folder Include="IntegrationEvents\Events\" />
|
||||||
<Folder Include="wwwroot\" />
|
<Folder Include="wwwroot\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.SignalR;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Basket.SignalrHub.IntegrationEvents;
|
|
||||||
using Serilog.Context;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Basket.SignalrHub.IntegrationEvents.EventHandling
|
|
||||||
{
|
|
||||||
public class UserAddedCartItemToBasketIntegrationEventHandler :
|
|
||||||
IIntegrationEventHandler<UserAddedCartItemToBasketIntegrationEvent>
|
|
||||||
{
|
|
||||||
private readonly IHubContext<NotificationsHub> _hubContext;
|
|
||||||
private readonly ILogger<UserAddedCartItemToBasketIntegrationEventHandler> _logger;
|
|
||||||
|
|
||||||
public UserAddedCartItemToBasketIntegrationEventHandler(
|
|
||||||
IHubContext<NotificationsHub> hubContext,
|
|
||||||
ILogger<UserAddedCartItemToBasketIntegrationEventHandler> logger)
|
|
||||||
{
|
|
||||||
_hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext));
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task Handle(UserAddedCartItemToBasketIntegrationEvent @event)
|
|
||||||
{
|
|
||||||
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("UpdateBasketCount", "test message");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Basket.SignalrHub.IntegrationEvents
|
|
||||||
{
|
|
||||||
public class BasketItem : IValidatableObject
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string ProductId { get; set; }
|
|
||||||
public string ProductName { get; set; }
|
|
||||||
public decimal UnitPrice { get; set; }
|
|
||||||
public decimal OldUnitPrice { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
public string PictureUrl { get; set; }
|
|
||||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
||||||
{
|
|
||||||
var results = new List<ValidationResult>();
|
|
||||||
|
|
||||||
if (Quantity < 1)
|
|
||||||
{
|
|
||||||
results.Add(new ValidationResult("Invalid number of units", new []{ "Quantity" }));
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Basket.SignalrHub.IntegrationEvents
|
|
||||||
{
|
|
||||||
public class UserAddedCartItemToBasketIntegrationEvent : IntegrationEvent
|
|
||||||
{
|
|
||||||
public string BuyerName { get; set; }
|
|
||||||
public BasketItem Item { get; set; }
|
|
||||||
|
|
||||||
public UserAddedCartItemToBasketIntegrationEvent(string buyerName, BasketItem basketItem)
|
|
||||||
{
|
|
||||||
BuyerName = buyerName;
|
|
||||||
Item = basketItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,8 +17,6 @@ using HealthChecks.UI.Client;
|
|||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Basket.SignalrHub.AutofacModules;
|
using Basket.SignalrHub.AutofacModules;
|
||||||
using Basket.SignalrHub.IntegrationEvents;
|
|
||||||
using Basket.SignalrHub.IntegrationEvents.EventHandling;
|
|
||||||
|
|
||||||
namespace Basket.SignalrHub
|
namespace Basket.SignalrHub
|
||||||
{
|
{
|
||||||
@ -162,7 +160,6 @@ namespace Basket.SignalrHub
|
|||||||
|
|
||||||
// Event bus subscribe events goes here
|
// Event bus subscribe events goes here
|
||||||
// eventBus.Subscribe<NewIntegrationEvent, NewIntegrationEventHandler>();
|
// eventBus.Subscribe<NewIntegrationEvent, NewIntegrationEventHandler>();
|
||||||
eventBus.Subscribe<UserAddedCartItemToBasketIntegrationEvent, UserAddedCartItemToBasketIntegrationEventHandler>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConfigureAuthService(IServiceCollection services)
|
private void ConfigureAuthService(IServiceCollection services)
|
||||||
|
@ -167,7 +167,7 @@ namespace Ordering.SignalrHub
|
|||||||
eventBus.Subscribe<OrderStatusChangedToShippedIntegrationEvent, OrderStatusChangedToShippedIntegrationEventHandler>();
|
eventBus.Subscribe<OrderStatusChangedToShippedIntegrationEvent, OrderStatusChangedToShippedIntegrationEventHandler>();
|
||||||
eventBus.Subscribe<OrderStatusChangedToCancelledIntegrationEvent, OrderStatusChangedToCancelledIntegrationEventHandler>();
|
eventBus.Subscribe<OrderStatusChangedToCancelledIntegrationEvent, OrderStatusChangedToCancelledIntegrationEventHandler>();
|
||||||
eventBus.Subscribe<OrderStatusChangedToSubmittedIntegrationEvent, OrderStatusChangedToSubmittedIntegrationEventHandler>();
|
eventBus.Subscribe<OrderStatusChangedToSubmittedIntegrationEvent, OrderStatusChangedToSubmittedIntegrationEventHandler>();
|
||||||
//eventBus.Subscribe<UserAddedCartItemToBasketIntegrationEvent, UserAddedCartItemToBasketIntegrationEventHandler>();
|
eventBus.Subscribe<UserAddedCartItemToBasketIntegrationEvent, UserAddedCartItemToBasketIntegrationEventHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConfigureAuthService(IServiceCollection services)
|
private void ConfigureAuthService(IServiceCollection services)
|
||||||
|
@ -266,8 +266,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
options.Scope.Add("marketing");
|
options.Scope.Add("marketing");
|
||||||
options.Scope.Add("locations");
|
options.Scope.Add("locations");
|
||||||
options.Scope.Add("webshoppingagg");
|
options.Scope.Add("webshoppingagg");
|
||||||
options.Scope.Add("orders.signalrhub");
|
options.Scope.Add("orders.signalrhub");
|
||||||
options.Scope.Add("basket.signalrhub");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
@ -81,7 +81,7 @@ export class SecurityService {
|
|||||||
let client_id = 'js';
|
let client_id = 'js';
|
||||||
let redirect_uri = location.origin + '/';
|
let redirect_uri = location.origin + '/';
|
||||||
let response_type = 'id_token token';
|
let response_type = 'id_token token';
|
||||||
let scope = 'openid profile orders basket marketing locations webshoppingagg orders.signalrhub basket.signalrhub';
|
let scope = 'openid profile orders basket marketing locations webshoppingagg orders.signalrhub';
|
||||||
let nonce = 'N' + Math.random() + '' + Date.now();
|
let nonce = 'N' + Math.random() + '' + Date.now();
|
||||||
let state = Date.now() + '' + Math.random();
|
let state = Date.now() + '' + Math.random();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user