/// <summary> /// Creates new event. /// </summary> /// <param name="eventType"></param> /// <param name="location"></param> /// <param name="registrationDate"></param> /// <param name="completionDate"></param> public HandlingEvent(HandlingEventType eventType, UnLocode location, DateTime registrationDate, DateTime completionDate) { _eventType = eventType; _completionDate = completionDate; _registrationDate = registrationDate; _location = location; }
/// <summary> /// Creates new leg instance. /// </summary> /// <param name="loadLocation">Location where cargo is supposed to be loaded.</param> /// <param name="loadDate">Date and time when cargo is supposed to be loaded</param> /// <param name="unloadLocation">Location where cargo is supposed to be unloaded.</param> /// <param name="unloadDate">Date and time when cargo is supposed to be unloaded.</param> public Leg(UnLocode loadLocation, DateTime loadDate, UnLocode unloadLocation, DateTime unloadDate) { _loadLocation = loadLocation; _unloadDate = unloadDate; _unloadLocation = unloadLocation; _loadDate = loadDate; }
/// <summary> /// Creates new leg instance. /// </summary> /// <param name="loadLocation">Location where cargo is supposed to be loaded.</param> /// <param name="loadDate">Date and time when cargo is supposed to be loaded</param> /// <param name="unloadLocation">Location where cargo is supposed to be unloaded.</param> /// <param name="unloadDate">Date and time when cargo is supposed to be unloaded.</param> public Leg(UnLocode loadLocation, DateTime loadDate, UnLocode unloadLocation, DateTime unloadDate) { LoadLocation = loadLocation; UnloadDate = unloadDate; UnloadLocation = unloadLocation; LoadDate = loadDate; }
public void ChangeDestination(TrackingId trackingId, UnLocode destinationUnLocode) { Location destination = _locationRepository.Find(destinationUnLocode); Cargo cargo = _cargoRepository.Find(trackingId); cargo.SpecifyNewRoute(destination); }
public void ChangeDestination(TrackingId trackingId, UnLocode destinationUnLocode) { Cargo cargo = _cargoRepository.Find(trackingId); Location destination = _locationRepository.Find(destinationUnLocode); RouteSpecification routeSpecification = new RouteSpecification(cargo.RouteSpecification.Origin, destination, cargo.RouteSpecification.ArrivalDeadline); cargo.SpecifyNewRoute(routeSpecification); }
public HandlingActivity(HandlingEventType eventType, UnLocode location) { if (location == null) { throw new ArgumentNullException("location"); } EventType = eventType; Location = location; }
/// <summary> /// Specifies a new route for this cargo. /// </summary> /// <param name="destination">New destination.</param> public virtual void SpecifyNewRoute(UnLocode destination) { if (destination == null) { throw new ArgumentNullException("destination"); } var routeSpecification = new RouteSpecification(RouteSpecification.Origin, destination, RouteSpecification.ArrivalDeadline); Publish(this, new CargoDestinationChangedEvent(routeSpecification, DeliveryStatus.Derive(routeSpecification, Itinerary))); }
public TrackingId BookNewCargo(UnLocode originUnLocode, UnLocode destinationUnLocode, DateTime arrivalDeadline) { Location origin = _locationRepository.Find(originUnLocode); Location destination = _locationRepository.Find(destinationUnLocode); RouteSpecification routeSpecification = new RouteSpecification(origin, destination, arrivalDeadline); TrackingId trackingId = _cargoRepository.NextTrackingId(); Cargo cargo = new Cargo(trackingId, routeSpecification); _cargoRepository.Store(cargo); return trackingId; }
public RouteSpecification(UnLocode origin, UnLocode destination, DateTime arrivalDeadline) { if (origin == null) { throw new ArgumentNullException("origin"); } if (destination == null) { throw new ArgumentNullException("destination"); } if (origin == destination) { throw new ArgumentException("Origin and destination can't be the same."); } Origin = origin; ArrivalDeadline = arrivalDeadline; Destination = destination; }
/// <summary> /// Creates new location. /// </summary> /// <param name="locode"><see cref="UnLocode"/> for this location.</param> /// <param name="name">Name.</param> public Location(UnLocode locode, string name) { UnLocode = locode; Name = name; }
private static void RegisterHandlingEvent(string cargoId, DateTime time, UnLocode location, HandlingEventType eventType) { InvokeCommand(new RegisterHandlingEventCommand { CargoId = cargoId, CompletionTime = time, Location = location.CodeString, Type = eventType }); }
/// <summary> /// Registers new handling event into the history. /// </summary> /// <param name="eventType">Type of the event.</param> /// <param name="location">Location where event occured.</param> /// <param name="registrationDate">Date when event was registered.</param> /// <param name="completionDate">Date when action represented by the event was completed.</param> public virtual void RegisterHandlingEvent(HandlingEventType eventType, UnLocode location, DateTime registrationDate, DateTime completionDate) { var @event = new HandlingEvent(eventType, location, registrationDate, completionDate); Publish(this, new CargoHandledEvent(Delivery.DerivedFrom(RouteSpecification, Itinerary, @event))); }
private static void RegisterHandlingEvent(DateTime completionTime, TrackingId trackingId, UnLocode occuranceLocation, HandlingEventType handlingEventType) { var registerHandlingEventCommand = new RegisterHandlingEventCommand() { CompletionTime = completionTime, OccuranceLocation = occuranceLocation.CodeString, TrackingId = trackingId.IdString, Type = handlingEventType }; CommandPipeline.Process(registerHandlingEventCommand); }
private Delivery(HandlingEvent lastHandlingEvent, Itinerary itinerary, RouteSpecification specification) { _calculatedAt = DateTime.Now; _lastEvent = lastHandlingEvent; _misdirected = CalculateMisdirectionStatus(itinerary, lastHandlingEvent); _routingStatus = CalculateRoutingStatus(itinerary, specification); _transportStatus = CalculateTransportStatus(lastHandlingEvent); _lastKnownLocation = CalculateLastKnownLocation(lastHandlingEvent); _eta = CalculateEta(itinerary); _nextExpectedActivity = CalculateNextExpectedActivity(specification, itinerary, lastHandlingEvent); _isUnloadedAtDestination = CalculateUnloadedAtDestination(specification, lastHandlingEvent); }
public Location.Location Find(UnLocode locode) { return _storage.FirstOrDefault(x => x.UnLocode == locode); }
public void RegisterHandlingEvent(DateTime completionTime, TrackingId trackingId, UnLocode unLocode, HandlingEventType type) { HandlingHistory handlingHistory = _handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId); Location location = _locationRepository.Find(unLocode); handlingHistory.RegisterHandlingEvent(type, location, DateTime.Now, completionTime); }
public Location.Location Find(UnLocode locode) { const string query = @"from DDDSample.Domain.Location.Location l where l.UnLocode = :unLocode"; return Session.CreateQuery(query).SetString("unLocode",locode.CodeString) .UniqueResult<Location.Location>(); }
public void RegisterHandlingEvent(DateTime completionTime, TrackingId trackingId, UnLocode unLocode, HandlingEventType type) { Cargo cargo = _cargoRepository.Find(trackingId); Location location = _locationRepository.Find(unLocode); cargo.RegisterHandlingEvent(type, location, DateTime.Now, completionTime); }