示例#1
0
        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 AddRegistryTrafficTicket(TrafficTicket t, vehicle v, DateTime time)
        {
            RpRegistryTrafficTickets rpRegistry = new RpRegistryTrafficTickets();
            RpDrivers     rpD   = new RpDrivers();
            List <Driver> ListD = rpD.GetDrivers().ToList();
            Driver        d     = null;

            foreach (Driver driver in ListD)
            {
                foreach (vehicle car in driver.listVehicles)
                {
                    if (car.Registration == v.Registration)
                    {
                        d = driver;
                        break;
                    }
                }
            }

            if (d != null)
            {
                return(rpRegistry.AddRegistryTrafficTicket(t, v, d, time));
            }
            else
            {
                //TODO mandar mensaje error
                return(false);
            }
        }
示例#3
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);
            }
        }
示例#4
0
        public Driver GetDriver(string DNI)
        {
            RpDrivers rpDrivers = new RpDrivers();

            return(rpDrivers.GetDriver(DNI));
        }
示例#5
0
        public List <Driver> GetDrivers()
        {
            RpDrivers rpDrivers = new RpDrivers();

            return(rpDrivers.GetDrivers().ToList());
        }