예제 #1
0
        /// <summary>
        /// Hires a driver.
        /// </summary>
        /// <param name="parameters">A string containing the driver id which will be hired, and the car id wich driver will drive, separated by a pipe.</param>
        public void HireDriver(string parameters)
        {
            string[] p = parameters.Split('|');
            if (p.Length < 2)
            {
                throw new ArgumentException("Invalid function parameter. Driver id and vehicle Id expected.");
            }

            int driverId;
            if (!int.TryParse(p[0], out driverId))
            {
                throw new ArgumentException("Invalid function parameter. Driver Id expected.");
            }

            int vehicleId;
            if (!int.TryParse(p[1], out vehicleId))
            {
                throw new ArgumentException("Invalid function parameter. Vehicle Id expected.");
            }

            DriverServices driverSvc = new DriverServices();
            Driver theDriver = driverSvc.GetById(driverId);

            VehicleServices vehicleSvc = new VehicleServices();
            Vehicle theCar = vehicleSvc.GetById(vehicleId);

            driverSvc.HireDriver(theDriver, theCar);
        }
예제 #2
0
 public HireDriverDialog(Driver notThisOne)
 {
     InitializeComponent();
     DriverServices dMgr = new DriverServices();
     IList<Driver> drivers = dMgr.GetAllDrivers();
     drivers.Remove(notThisOne);
     this.DataContext = drivers;
 }
예제 #3
0
        /// <summary>
        /// Fires a driver.
        /// </summary>
        /// <param name="parameters">A string containing the car id wich driver will be fired.</param>
        public void FireDriver(string parameters)
        {
            int vehicleId;
            if (!int.TryParse(parameters, out vehicleId))
            {
                throw new ArgumentException("Invalid function parameter. Vehicle Id expected.");
            }

            VehicleServices vehicleSvc = new VehicleServices();
            Vehicle theCar = vehicleSvc.GetById(vehicleId);

            DriverServices driverSvc = new DriverServices();
            driverSvc.FireDriver(theCar);
        }