-
-
Save dcomartin/bfed804af174361b0b070d8e0fadd28b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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