コード例 #1
0
ファイル: VehicleController.cs プロジェクト: rgamex/PruebaDGT
        public bool AddVehicleToDrive(string registration, string brand, string model, string dni)
        {
            RpVehicles rpVehicle = new RpVehicles();
            RpDrivers  rpDrivers = new RpDrivers();

            try
            {
                //TODO Validar matrícula antes de agregar el vehículo rpVehicle.AddVehicle
                if (!rpVehicle.checkExistVehicle(registration) && rpDrivers.checkExistDNI(dni))
                {
                    Driver  conductor = rpDrivers.GetDriver(dni);
                    vehicle car       = new vehicle(registration, brand, model);
                    if (rpVehicle.AddVehicle(car))
                    {
                        return(conductor.addVehicle(car));
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                else
                {
                    return(false);
                }
            } catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #2
0
        public bool AddDriver(string dni, string name, string lastName, int point)
        {
            RpDrivers rpDrivers = new RpDrivers();

            if (!rpDrivers.checkExistDNI(dni))
            {
                Driver NewDriver = new Driver(dni, name, lastName, point);
                return(rpDrivers.AddDriver(NewDriver));
            }
            else
            {
                return(false);
            }
        }