Skip to content

Instantly share code, notes, and snippets.

@ahmetkucukoglu
Created November 3, 2023 19:41
Show Gist options
  • Save ahmetkucukoglu/23cee9de55f1ed08dab16f29f32d5ab8 to your computer and use it in GitHub Desktop.
Save ahmetkucukoglu/23cee9de55f1ed08dab16f29f32d5ab8 to your computer and use it in GitHub Desktop.
Context - Shipment
public class Shipment
{
public Guid OrderId { get; private set; }
public string FromCountry { get; private set; }
public string To { get; private set; }
public ShipmentState State { get; private set; }
public int DeliveryAttempts { get; internal set; }
public Shipment(Guid orderId, string fromCountry, string to)
{
OrderId = orderId;
FromCountry = fromCountry;
To = to;
State = new OrderPlacedState();
}
public void MoveTo(ShipmentState state)
{
State = state;
}
public void ToInTransit()
{
State.InTransit(this);
}
public void ToInCustoms()
{
State.InCustoms(this);
}
public void ToCustomsCleared()
{
State.CustomsCleared(this);
}
public void ToOutForDelivery()
{
State.OutForDelivery(this);
}
public void ToDelivered()
{
State.Delivered(this);
}
public void ToNotDelivered()
{
State.NotDelivered(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment