public static Courier <Vehicle> CreateNewVehicle(AdminAddUpdateVehicleVM model) { VehicleManager mgr = new VehicleManager(); int nameplateId = int.Parse(model.NameplateId); int year = int.Parse(model.ProductionYear); int mileage = int.Parse(model.Mileage); decimal msrp = decimal.Parse(model.MSRP); decimal saleprice = decimal.Parse(model.SalePrice); bool trans = model.SelectedTransmission == "Automatic"; Vehicle newItem = new Vehicle() { VIN = model.VIN, Description = model.Description, ImageFileName = model.ImageFileName, Featured = model.Featured, ExteriorColor = SetExteriorColor(model.BodyColor), InteriorColor = SetInteriorColor(model.InteriorColor), NameplateId = nameplateId, ProductionYear = year, Mileage = mileage, MSRP = msrp, SalePrice = saleprice, Transmission = trans }; return(mgr.CreateNewVehicle(newItem)); }
private void addNewVehicleUI() { VehicleProperties.eStateOfService statusOfNewVehicle; Dictionary <string, object> basicArgumentsMap = new Dictionary <string, object>(); string plateNumber = getStringFromUser(Strings.enter_plate_number); try { VehicleProperties vehicle = m_Garage.GetVehicleByPlateNumber(plateNumber); printMessage(string.Format(Strings.change_status_options, VehicleProperties.s_StateListOptions[(int)vehicle.Status])); showOptions(VehicleProperties.s_StateListOptions); statusOfNewVehicle = (VehicleProperties.eStateOfService)getUserChoice(1, VehicleProperties.s_StateListOptions.Count) - 1; vehicle.Status = statusOfNewVehicle; } catch (Exception i_PlateError) { if (i_PlateError is KeyNotFoundException) { showError(string.Format(Strings.plate_didnt_found, plateNumber)); } else { showError(Strings.unknown_error); } printMessage(Strings.create_new_vehicle); VehicleManager.eVehicleTypes vehicleType = getOptionFromUser <VehicleManager.eVehicleTypes>(Strings.choose_type_of_vehicle, VehicleManager.VehicleList, -1); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyTypeOfVehicle, vehicleType); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyOwnerName, getStringFromUser(Strings.enter_owner_name)); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyPhoneNumber, getStringFromUser(Strings.enter_phone_number)); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyModelName, getStringFromUser(Strings.enter_model_name)); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyWheelManufacturer, getStringFromUser(Strings.enter_wheel_manufacturer)); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyPlateNumber, plateNumber); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyRepairStatus, getOptionFromUser <VehicleProperties.eStateOfService>(Strings.choose_status_of_vehicle, VehicleProperties.s_StateListOptions, -1)); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyCurrentEnergyLevel, getFloatFromUser(Strings.enter_current_energy_level)); basicArgumentsMap.Add(ArgumentsKeysets.sr_KeyCurrentWheelPressure, getFloatFromUser(Strings.enter_current_wheel_pressure_level)); getMoreInformationBasedOnType(VehicleManager.s_OptionsToAskUserByTypes[vehicleType], ref basicArgumentsMap); m_Garage.AddNewVehicle(VehicleManager.CreateNewVehicle(ref basicArgumentsMap), ref basicArgumentsMap); } }