remove CheckValidSagaId replicated method
This commit is contained in:
parent
ea1c50db7b
commit
e6c59f093c
@ -3,6 +3,7 @@
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
|
||||
using Ordering.API.Application.IntegrationEvents.Events;
|
||||
using Ordering.Domain.Exceptions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class OrderPaymentFailedIntegrationEventHandler :
|
||||
@ -17,7 +18,9 @@
|
||||
|
||||
public async Task Handle(OrderPaymentFailedIntegrationEvent @event)
|
||||
{
|
||||
//TODO: Cancel Order
|
||||
var orderToUpdate = await _orderRepository.GetAsync(@event.OrderId);
|
||||
|
||||
orderToUpdate.SetCancelledStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,18 +18,9 @@
|
||||
|
||||
public async Task Handle(OrderPaymentSuccededIntegrationEvent @event)
|
||||
{
|
||||
var order = await _orderRepository.GetAsync(@event.OrderId);
|
||||
CheckValidSagaId(order);
|
||||
var orderToUpdate = await _orderRepository.GetAsync(@event.OrderId);
|
||||
|
||||
order.SetPaidStatus();
|
||||
}
|
||||
|
||||
private void CheckValidSagaId(Order orderSaga)
|
||||
{
|
||||
if (orderSaga is null)
|
||||
{
|
||||
throw new OrderingDomainException("Not able to process order saga event. Reason: no valid orderId");
|
||||
}
|
||||
orderToUpdate.SetPaidStatus();
|
||||
}
|
||||
}
|
||||
}
|
@ -19,18 +19,9 @@
|
||||
|
||||
public async Task Handle(OrderStockConfirmedIntegrationEvent @event)
|
||||
{
|
||||
var order = await _orderRepository.GetAsync(@event.OrderId);
|
||||
CheckValidSagaId(order);
|
||||
var orderToUpdate = await _orderRepository.GetAsync(@event.OrderId);
|
||||
|
||||
order.SetStockConfirmedStatus();
|
||||
}
|
||||
|
||||
private void CheckValidSagaId(Order orderSaga)
|
||||
{
|
||||
if (orderSaga is null)
|
||||
{
|
||||
throw new OrderingDomainException("Not able to process order saga event. Reason: no valid orderId");
|
||||
}
|
||||
orderToUpdate.SetStockConfirmedStatus();
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ namespace Ordering.API.Application.IntegrationEvents.EventHandling
|
||||
public async Task Handle(OrderStockNotConfirmedIntegrationEvent @event)
|
||||
{
|
||||
var orderToUpdate = await _orderRepository.GetAsync(@event.OrderId);
|
||||
CheckValidSagaId(orderToUpdate);
|
||||
|
||||
var orderStockNotConfirmedItems = @event.OrderStockItems
|
||||
.FindAll(c => !c.Confirmed)
|
||||
@ -30,13 +29,5 @@ namespace Ordering.API.Application.IntegrationEvents.EventHandling
|
||||
|
||||
orderToUpdate.SetStockConfirmedStatus(orderStockNotConfirmedItems);
|
||||
}
|
||||
|
||||
private void CheckValidSagaId(Order orderSaga)
|
||||
{
|
||||
if (orderSaga is null)
|
||||
{
|
||||
throw new OrderingDomainException("Not able to process order saga event. Reason: no valid orderId");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user