public void CanAddVehicle() { AddVehicleObject vehicle = new AddVehicleObject() { VIN = "1GC0KXCG9DF173160", Interior = "White", Transmission = "Automatic", Mileage = "11223", MSRP = 12000, SalePrice = 10455, Color = "Black", BodyStyle = "Sedan", Description = "Nice well maintained and hardly driven car", Make = "Dodge", Model = "Charger", Type = "Used", Year = 2001 }; var repo = new VehicleRepository(); repo.AddVehicle(vehicle); // Now check in the DB if the record was added }
public IActionResult Add(Vehicle vehicle) { if (vehicle.Type.Equals("1")) { vehicle.Type = "Otomobil"; } else if (vehicle.Type.Equals("2")) { vehicle.Type = "Kamyonet"; } else if (vehicle.Type.Equals("3")) { vehicle.Type = "Kamyon"; } else if (vehicle.Type.Equals("4")) { vehicle.Type = "Otobüs"; } else if (vehicle.Type.Equals("5")) { vehicle.Type = "Motosiklet"; } VehicleRepository.AddVehicle(vehicle); return(RedirectToAction("Index")); }
public void Test_AddVehicle_When_InvalidVin_ShouldReturnFalse() { //length string invalidVin = "ABCDEFGH"; _vehicleRepository.ClearRepository(); Assert.IsFalse(_vehicleRepository.AddVehicle("HONDA", "2004", "CR", invalidVin, VehicleTypes.Semi, VehicleStatus.StandBy)); //Ending with 5 numeric invalidVin = "1234567891234567891ABCDE"; Assert.IsFalse(_vehicleRepository.AddVehicle("HONDA", "2004", "CR", invalidVin, VehicleTypes.Semi, VehicleStatus.StandBy)); //Minimum of 8 alphas invalidVin = "1234abcd1234567891234567"; Assert.IsFalse(_vehicleRepository.AddVehicle("HONDA", "2004", "CR", invalidVin, VehicleTypes.Semi, VehicleStatus.StandBy)); }
public void SeedRepository() { Electric leaf = new Electric("Nissan", "Leaf", 2019, 4.9, 42000, Chance.Low); Electric tesla = new Electric("Tesla", "Model S", 2016, 4.8, 55000, Chance.Medium); Gas tundra = new Gas("Toyota", "Tundra", 2017, 4.6, 46000, true); Gas impala = new Gas("Chevrolet", "Impala", 2016, 4.7, 36000, false); Hybrid prius = new Hybrid("Toyota", "Prius", 2014, 4.6, 27000); _vehicleRepo.AddVehicle(leaf); _vehicleRepo.AddVehicle(tesla); _vehicleRepo.AddVehicle(tundra); _vehicleRepo.AddVehicle(impala); _vehicleRepo.AddVehicle(prius); }
private void AddOrUpdateVehicle(Vehicle vehicle) { if (vehicle == null) { Stdout("There is no current vehicle to add or update."); return; } var myVehicle = new MyVehicle(vehicle); if (_vehicleRepository.UpdateVehicle(myVehicle, saveToDisk: true)) { Stdout($"Successfully updated vehicle '{myVehicle.ModelName}' with license plate '{myVehicle.LicensePlate}'."); } else if (_vehicleRepository.AddVehicle(myVehicle, saveToDisk: true)) { Stdout($"Successfully added vehicle '{myVehicle.ModelName}' with license plate '{myVehicle.LicensePlate}'."); } else { Stdout("Couldn't add or update vehicle."); } }
public IActionResult CarEntry(Vehicle vehicle) { VehicleRepository.AddVehicle(vehicle); return(RedirectToAction("Index")); }
public void BlankStateDatabase() { SampleVehicleRepository seedVehicles = new SampleVehicleRepository(); SampleSpecialRepository seedSpecials = new SampleSpecialRepository(); SamplePurchaseRepository seedPurchases = new SamplePurchaseRepository(); SampleContactRepository seedContact = new SampleContactRepository(); var mSeed = seedVehicles.GetMakes(); var nSeed = seedVehicles.GetModels(); var sSeed = seedSpecials.GetSpecials(); var pSeed = seedPurchases.GetAllPurchases(); var cSeed = seedContact.GetAll(); List <Vehicle> vSeed = new List <Vehicle>(); SeedManager sMgr = new SeedManager(); for (int i = 0; i < 500; i++) { var v = sMgr.PlantACar(nSeed.Max(n => n.NameplateId)); v.Model = nSeed.FirstOrDefault(n => n.NameplateId == v.NameplateId); vSeed.Add(v); } VehicleRepository vRepo = new VehicleRepository(); SpecialRepository sRepo = new SpecialRepository(); PurchaseRepository pRepo = new PurchaseRepository(); ContactRepository cRepo = new ContactRepository(); foreach (var m in mSeed) { vRepo.AddMake(m); } foreach (var n in nSeed) { n.ManufacturerId = n.Manufacturer.ManufacturerId; vRepo.AddModel(n); } foreach (var v in vSeed) { if (v.ImageFileName == null || v.ImageFileName.Length < 4) { switch (v.Model.BodyStyle) { case BodyStyle.Car: v.ImageFileName = "Car.png"; break; case BodyStyle.SUV: v.ImageFileName = "SUV.png"; break; case BodyStyle.Truck: v.ImageFileName = "Truck.png"; break; case BodyStyle.Van: v.ImageFileName = "Van.png"; break; default: throw new Exception("A vehicle's model's body style data was corrupt."); } } v.NameplateId = v.Model.NameplateId; vRepo.AddVehicle(v); } foreach (var s in sSeed) { sRepo.AddSpecial(s); } foreach (var p in pSeed) { pRepo.AddPurchase(p); } foreach (var c in cSeed) { cRepo.Add(c); } }