Skip to content

Commit 1218069

Browse files
committed
Removed Saga feature
1 parent ce2083d commit 1218069

6 files changed

Lines changed: 121 additions & 174 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using MediatR;
2+
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
3+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
4+
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
10+
namespace Ordering.API.Application.Commands
11+
{
12+
public class CancelOrderCommandIdentifiedHandler : IdentifierCommandHandler<CancelOrderCommand, bool>
13+
{
14+
public CancelOrderCommandIdentifiedHandler(IMediator mediator, IRequestManager requestManager) : base(mediator, requestManager)
15+
{
16+
}
17+
18+
protected override bool CreateResultForDuplicateRequest()
19+
{
20+
return true; // Ignore duplicate requests for processing order.
21+
}
22+
}
23+
24+
public class CancelOrderCommandHandler : IAsyncRequestHandler<CancelOrderCommand, bool>
25+
{
26+
private readonly IOrderRepository _orderRepository;
27+
28+
public CancelOrderCommandHandler(IOrderRepository orderRepository)
29+
{
30+
_orderRepository = orderRepository;
31+
}
32+
33+
/// <summary>
34+
/// Handler which processes the command when
35+
/// customer executes cancel order from app
36+
/// </summary>
37+
/// <param name="command"></param>
38+
/// <returns></returns>
39+
public async Task<bool> Handle(CancelOrderCommand command)
40+
{
41+
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
42+
orderToUpdate.SetCancelledStatus();
43+
return await _orderRepository.UnitOfWork.SaveEntitiesAsync();
44+
}
45+
}
46+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using MediatR;
2+
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
3+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
4+
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
5+
using System.Threading.Tasks;
6+
7+
namespace Ordering.API.Application.Commands
8+
{
9+
public class ShipOrderCommandIdentifiedHandler : IdentifierCommandHandler<ShipOrderCommand, bool>
10+
{
11+
public ShipOrderCommandIdentifiedHandler(IMediator mediator, IRequestManager requestManager) : base(mediator, requestManager)
12+
{
13+
}
14+
15+
protected override bool CreateResultForDuplicateRequest()
16+
{
17+
return true; // Ignore duplicate requests for processing order.
18+
}
19+
}
20+
21+
public class ShipOrderCommandHandler : IAsyncRequestHandler<ShipOrderCommand, bool>
22+
{
23+
private readonly IOrderRepository _orderRepository;
24+
25+
public ShipOrderCommandHandler(IOrderRepository orderRepository)
26+
{
27+
_orderRepository = orderRepository;
28+
}
29+
30+
/// <summary>
31+
/// Handler which processes the command when
32+
/// administrator executes ship order from app
33+
/// </summary>
34+
/// <param name="command"></param>
35+
/// <returns></returns>
36+
public async Task<bool> Handle(ShipOrderCommand command)
37+
{
38+
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
39+
orderToUpdate.SetShippedStatus();
40+
return await _orderRepository.UnitOfWork.SaveEntitiesAsync();
41+
}
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
2+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
3+
using Ordering.API.Application.IntegrationEvents.Events;
4+
using System.Threading.Tasks;
5+
6+
namespace Ordering.API.Application.IntegrationEvents.EventHandling
7+
{
8+
public class GracePeriodConfirmedIntegrationEventHandler : IIntegrationEventHandler<GracePeriodConfirmedIntegrationEvent>
9+
{
10+
private readonly IOrderRepository _orderRepository;
11+
12+
public GracePeriodConfirmedIntegrationEventHandler(IOrderRepository orderRepository)
13+
{
14+
_orderRepository = orderRepository;
15+
}
16+
17+
/// <summary>
18+
/// Event handler which confirms that the grace period
19+
/// has been completed and order will not initially be cancelled.
20+
/// Therefore, the order process continues for validation.
21+
/// </summary>
22+
/// <param name="event">
23+
/// </param>
24+
/// <returns></returns>
25+
public async Task Handle(GracePeriodConfirmedIntegrationEvent @event)
26+
{
27+
var orderToUpdate = await _orderRepository.GetAsync(@event.OrderId);
28+
orderToUpdate.SetAwaitingValidationStatus();
29+
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
30+
}
31+
}
32+
}

src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs

Lines changed: 0 additions & 121 deletions
This file was deleted.

src/Services/Ordering/Ordering.API/Application/Sagas/OrderSaga.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Services/Ordering/Ordering.API/Application/Sagas/Saga.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)