Пример #1
0
        /// <summary>
        /// Creates a new instance of a workshop-planning for the specified date.
        /// </summary>
        /// <param name="date">The date to create the planning for.</param>
        /// <param name="planning">The initialized WorkshopPlanning instance.</param>
        /// <returns>The WorkshopPlanningCreated event.</returns>
        /// <remarks>This implementation makes sure creation of the planning becomes part of the event-stream.</remarks>
        public static IEnumerable <Event> Create(DateTime date, out WorkshopPlanning planning)
        {
            planning = new WorkshopPlanning();
            WorkshopPlanningCreated e = new WorkshopPlanningCreated(Guid.NewGuid(), date);

            return(planning.HandleEvent(e));
        }
Пример #2
0
 public static void PlannedMaintenanceJobShouldFallWithinOneBusinessDay(
     this WorkshopPlanning planning, PlanMaintenanceJob command)
 {
     if (command.StartTime.Date != command.EndTime.Date)
     {
         throw new BusinessRuleViolationException("Start-time and end-time of a Maintenance Job must be within a 1 day.");
     }
 }
Пример #3
0
        /// <summary>
        /// Creates a new instance of a workshop-planning for the specified date.
        /// </summary>
        /// <param name="date">The date to create the planning for.</param>
        public static WorkshopPlanning Create(DateTime date)
        {
            WorkshopPlanning        planning = new WorkshopPlanning(date);
            WorkshopPlanningCreated e        = new WorkshopPlanningCreated(Guid.NewGuid(), date);

            planning.RaiseEvent(e);
            return(planning);
        }
Пример #4
0
 public static void NumberOfParallelMaintenanceJobsOnAVehicleIsOne(
     this WorkshopPlanning planning, PlanMaintenanceJob command)
 {
     if (planning.Jobs.Any(j => j.Vehicle.LicenseNumber == command.VehicleInfo.LicenseNumber &&
                           (j.StartTime >= command.StartTime && j.StartTime <= command.EndTime ||
                            j.EndTime >= command.StartTime && j.EndTime <= command.EndTime)))
     {
         throw new BusinessRuleViolationException($"Only 1 maintenance job can be executed on a vehicle during a certain time-slot.");
     }
 }
Пример #5
0
 public static void NumberOfParallelMaintenanceJobsMustNotExceedAvailableWorkStations(
     this WorkshopPlanning planning, PlanMaintenanceJob command)
 {
     if (planning.Jobs.Count(j =>
                             (j.StartTime >= command.StartTime && j.StartTime <= command.EndTime) ||
                             (j.EndTime >= command.StartTime && j.EndTime <= command.EndTime)) >= AVAILABLE_WORKSTATIONS)
     {
         throw new BusinessRuleViolationException($"Maintenancejob overlaps with more than {AVAILABLE_WORKSTATIONS} other jobs.");
     }
 }