Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created December 1, 2025 22:32
Show Gist options
  • Select an option

  • Save dcomartin/bfed804af174361b0b070d8e0fadd28b to your computer and use it in GitHub Desktop.

Select an option

Save dcomartin/bfed804af174361b0b070d8e0fadd28b to your computer and use it in GitHub Desktop.
public class UpdateShipmentStatus
{
public int ShipmentId { get; set; }
public ShipmentStatus Status { get; set; }
}
public class ShipmentHandler
{
private readonly IRepository<Shipment> _shipmentRepository;
public ShipmentHandler(IRepository<Shipment> shipmentRepository)
{
_shipmentRepository = shipmentRepository;
}
public void Handle(UpdateShipmentStatus request)
{
var shipment = _shipmentRepository.Get(request.ShipmentId);
shipment.UpdateStatus(request.Status);
_shipmentRepository.Save(shipment);
}
}
public enum ShipmentStatus { ArrivedAtShipper, DepartedShipper }
public class Shipment : Entity
{
public ShipmentStatus CurrentStatus { get; private set; }
public void UpdateStatus(ShipmentStatus newStatus)
{
CurrentStatus = newStatus;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment