Пример #1
0
    private void Handle(MaintenanceJobPlanned e)
    {
        MaintenanceJob job             = new MaintenanceJob(e.JobId);
        Customer       customer        = new Customer(e.CustomerInfo.Id, e.CustomerInfo.Name, e.CustomerInfo.TelephoneNumber);
        LicenseNumber  licenseNumber   = LicenseNumber.Create(e.VehicleInfo.LicenseNumber);
        Vehicle        vehicle         = new Vehicle(licenseNumber, e.VehicleInfo.Brand, e.VehicleInfo.Type, customer.Id);
        Timeslot       plannedTimeslot = Timeslot.Create(e.StartTime, e.EndTime);

        job.Plan(plannedTimeslot, vehicle, customer, e.Description);
        Jobs.Add(job);
    }
Пример #2
0
        public MaintenanceJob Build()
        {
            if (Customer == null)
            {
                throw new InvalidOperationException("You must specify a customer using the 'WithCustomer' method.");
            }

            if (Vehicle == null)
            {
                throw new InvalidOperationException("You must specify a vehicle using the 'WithVehicle' method.");
            }

            var job = new MaintenanceJob();

            job.Plan(Id, StartTime, EndTime, Vehicle, Customer, Description);
            return(job);
        }
        public MaintenanceJob Build()
        {
            if (CustomerBuilder == null)
            {
                throw new InvalidOperationException("You must specify a customerbuilder using the 'WithCustomerBuilder' method.");
            }

            if (VehicleBuilder == null)
            {
                throw new InvalidOperationException("You must specify a vehiclebuilder using the 'WithVehicleBuilder' method.");
            }

            Customer customer = CustomerBuilder.Build();
            Vehicle  vehicle  = VehicleBuilder.Build();

            var      job             = new MaintenanceJob();
            Timeslot plannedTimeslot = Timeslot.Create(StartTime, EndTime);

            job.Plan(JobId, plannedTimeslot, vehicle, customer, Description);
            return(job);
        }