-
-
Save dcomartin/43157e753caddd787dd3f711901978e5 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 Dispatcher | |
| { | |
| public Guid Id { get; private set; } | |
| public string AssignedRegion { get; private set; } | |
| public Dispatcher(Guid id, string assignedRegion) | |
| { | |
| Id = id; | |
| AssignedRegion = assignedRegion; | |
| } | |
| } | |
| public class Shipment | |
| { | |
| public Guid Id { get; private set; } | |
| public string Region { get; private set; } | |
| public Guid? AssignedDriverId { get; private set; } | |
| public Shipment(Guid id, string region) | |
| { | |
| Id = id; | |
| Region = region; | |
| AssignedDriverId = null; | |
| } | |
| public void AssignDriver(Guid driverId, Dispatcher dispatcher) | |
| { | |
| if (dispatcher.AssignedRegion != Region) | |
| { | |
| throw new UnauthorizedAccessException("Dispatcher cannot assign a load outside their assigned region."); | |
| } | |
| AssignedDriverId = driverId; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment