Exemplo n.º 1
0
        public Truck(
            int km,
            string licensePlate,
            string brand,
            string model,
            ITruckUniquenessChecker uniquenessTruckChecker)
        {
            uniquenessTruckChecker = uniquenessTruckChecker ?? throw new Exception($"Invalid {nameof(uniquenessTruckChecker)}");

            if (!uniquenessTruckChecker.IsLicensePlateUnique(licensePlate))
            {
                throw new Exception("Invalid checker");
            }

            if (km < 0)
            {
                throw new Exception("Invalid checker");
            }

            Km           = km;
            LicensePlate = new LicensePlate(licensePlate);
            Brand        = brand;
            Model        = model;
            CreatedAt    = DateTime.Now;
        }
Exemplo n.º 2
0
 public RegisterTruckHandler(
     ITruckUniquenessChecker truckUniquenessChecker,
     IVehicleService vehicleService,
     IResponse <Truck, TruckRegisteredResponse> truckRegisteredResponse)
 {
     _truckUniquenessChecker  = truckUniquenessChecker;
     _vehicleService          = vehicleService;
     _truckRegisteredResponse = truckRegisteredResponse;
 }