コード例 #1
0
        private void AddVehicle()
        {
            Vehicle vehicle;
            var     plate = _ioHelper.GetTextFromUser("Enter the licence plate");

            if (_vehiclesService.FindByPlate(plate))
            {
                _ioHelper.DisplayInfo("Vehicle with given plates number already exists!\n", MessageType.Error);
                return;
            }

            vehicle = new Vehicle()
            {
                Make     = _ioHelper.GetTextFromUser("Enter vehicle\'s make"),
                Model    = _ioHelper.GetTextFromUser("Enter vehicle\'s model"),
                Plate    = plate,
                Capacity = _ioHelper.GetUintFromUser("Enter vehicle\'s capacity [kg]"),
            };

            do
            {
                vehicle.UserId = _usersService.GetUserId(_ioHelper.GetTextFromUser("Enter courier\'s email"));
            } while (!_usersService.CheckIfValidCourier(vehicle.UserId) || vehicle.UserId == 0);

            _vehiclesService.Add(vehicle);

            _ioHelper.DisplayInfo("Vehicle added successfully!\n", MessageType.Success);
        }