remove CheckValidSagaId replicated method

This commit is contained in:
Christian Arenas 2017-05-16 10:18:57 +02:00
parent ea1c50db7b
commit e6c59f093c
4 changed files with 8 additions and 32 deletions

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -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");
}
}
}
}