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
using System.Threading.Tasks; | |
using DotNetCore.CAP; | |
using Microsoft.EntityFrameworkCore; | |
using Sales.Contracts; | |
namespace Shipping | |
{ | |
public class CancelShippingLabel : ICapSubscribe | |
{ | |
private readonly ShippingDbContext _dbContext; | |
public CancelShippingLabel(ShippingDbContext dbContext) | |
{ | |
_dbContext = dbContext; | |
} | |
[CapSubscribe(nameof(OrderPlaced))] | |
public async Task Handle(OrderCancelled orderCancelled) | |
{ | |
var order = await _dbContext.ShippingLabels.SingleAsync(x => x.OrderId == orderCancelled.OrderId); | |
order.Cancelled = true; | |
await _dbContext.SaveChangesAsync(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment