Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created December 2, 2020 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/ea33035dc969cad6c4dbd4e5f05d57d3 to your computer and use it in GitHub Desktop.
Save dcomartin/ea33035dc969cad6c4dbd4e5f05d57d3 to your computer and use it in GitHub Desktop.
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