Created
November 3, 2023 19:41
-
-
Save ahmetkucukoglu/23cee9de55f1ed08dab16f29f32d5ab8 to your computer and use it in GitHub Desktop.
Context - Shipment
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
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