forked from ebubekirdinc/SuuCat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notification service added to the Saga
- Loading branch information
1 parent
6de6f87
commit 6132c13
Showing
50 changed files
with
308 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Services/Notification/src/Infrastructure/Consumers/OrderCompletedEventConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using MassTransit; | ||
using Microsoft.Extensions.Logging; | ||
using Shared.Events.Interfaces; | ||
|
||
namespace Notification.Infrastructure.Consumers; | ||
|
||
public class OrderCompletedEventConsumer : IConsumer<IOrderCompletedEvent> | ||
{ | ||
private readonly ILogger<OrderCompletedEventConsumer> _logger; | ||
|
||
public OrderCompletedEventConsumer(ILogger<OrderCompletedEventConsumer> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public async Task Consume(ConsumeContext<IOrderCompletedEvent> context) | ||
{ | ||
// TODO: Send email to customer | ||
|
||
_logger.LogInformation($"Order (Id={context.Message.OrderId}) Order Completed notification sent"); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Services/Notification/src/Infrastructure/Consumers/OrderFailedEventConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using MassTransit; | ||
using Microsoft.Extensions.Logging; | ||
using Shared.Events.Interfaces; | ||
|
||
namespace Notification.Infrastructure.Consumers; | ||
|
||
public class OrderFailedEventConsumer : IConsumer<IOrderFailedEvent> | ||
{ | ||
private readonly ILogger<OrderFailedEventConsumer> _logger; | ||
|
||
public OrderFailedEventConsumer(ILogger<OrderFailedEventConsumer> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public async Task Consume(ConsumeContext<IOrderFailedEvent> context) | ||
{ | ||
// TODO: Send email to customer | ||
|
||
_logger.LogInformation($"Order (Id={context.Message.OrderId}) Order Completed notification sent"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
using Notification.Infrastructure; | ||
using Notification.Infrastructure.Persistence; | ||
using WebUI.Middlewares; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Services/Payment/src/Infrastructure/Consumers/CompletePaymentMessageConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using MassTransit; | ||
using Microsoft.Extensions.Logging; | ||
using Shared.Events; | ||
using Shared.Messages.Interfaces; | ||
|
||
namespace Payment.Infrastructure.Consumers; | ||
|
||
public class CompletePaymentMessageConsumer : IConsumer<ICompletePaymentMessage> | ||
{ | ||
private readonly ILogger<CompletePaymentMessageConsumer> _logger; | ||
|
||
private readonly IPublishEndpoint _publishEndpoint; | ||
|
||
public CompletePaymentMessageConsumer(ILogger<CompletePaymentMessageConsumer> logger, IPublishEndpoint publishEndpoint) | ||
{ | ||
_logger = logger; | ||
_publishEndpoint = publishEndpoint; | ||
} | ||
|
||
public async Task Consume(ConsumeContext<ICompletePaymentMessage> context) | ||
{ | ||
var balance = 3000m; | ||
|
||
if (balance > context.Message.TotalPrice) | ||
{ | ||
_logger.LogInformation($"{context.Message.TotalPrice} was withdrawn from credit card for user id= {context.Message.CustomerId}"); | ||
|
||
await _publishEndpoint.Publish(new PaymentCompletedEvent(context.Message.CorrelationId)); | ||
} | ||
else | ||
{ | ||
_logger.LogInformation($"{context.Message.TotalPrice} was not withdrawn from credit card for user id={context.Message.CustomerId}"); | ||
|
||
await _publishEndpoint.Publish(new PaymentFailedEvent(context.Message.CorrelationId) { Reason = "not enough balance", OrderItems = context.Message.OrderItems }); | ||
} | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
src/Services/Payment/src/Infrastructure/Consumers/StockReservedRequestPaymentConsumer.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.