Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created October 22, 2025 15:21
Show Gist options
  • Save dcomartin/43157e753caddd787dd3f711901978e5 to your computer and use it in GitHub Desktop.
Save dcomartin/43157e753caddd787dd3f711901978e5 to your computer and use it in GitHub Desktop.
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