public IActionResult Index(ItemsListsViewModel itemsLists) { ViewBag.CarList = Car_Repo.GetAll().ToList(); ViewBag.DetailList = Detail_Repo.GetAll().ToList(); ViewBag.ConfigurationList = Config_Repo.GetAll().ToList(); ItemsListsViewModel items = new ItemsListsViewModel() { ItemIdSelected = 1 }; return(View(itemsLists)); }
public IActionResult EditCar(int ItemIdSelected) { Car kek = Car_Repo.GetAll().FirstOrDefault(x => x.Id == ItemIdSelected); if (kek == null) { ViewBag.ErrorMesage = $"Car with id {kek.Id} cannot be found"; return(View("NotFound")); } return(View(kek)); }
public void AddCar_ShouldGetCorrectBool() //Create { //Arrange HybridCar hybridCar = new HybridCar(); Car_Repo repo = new Car_Repo(); //Act bool addResult = repo.AddCar(hybridCar); //Assert Assert.IsTrue(addResult); }
public void GetAllCars_ShouldReturnCorrectCollection() //Read { //Arrange GasCar car = new GasCar("ford", "mustang", 2020); Car_Repo repo = new Car_Repo(); repo.AddCar(car); //Act List <Car> localCars = repo.GetAllCars(); bool hasCar = localCars.Contains(car); //Assert Assert.IsTrue(hasCar); }
public IActionResult EditCar(Car car) { Car kek = Car_Repo.GetAll().FirstOrDefault(x => x.Id == car.Id); if (kek == null) { ViewBag.ErrorMesage = $"Car with id {car.Id} cannot be found"; return(View("NotFound")); } else { Car_Repo.Edit(car); } return(View("/Views/Home/Index.cshtml")); }
public void UpdateExistingCar_ShouldReturnTrue() //Update a car { //Arrange GasCar car = new GasCar("ford", "mustang", 2020); GasCar car2 = new GasCar("toyota", "camry", 2019, VehicleType.Sedan, 624, 32); Car_Repo repo = new Car_Repo(); repo.AddCar(car); string id = "2020fordmustang"; //Act bool UpdateResult = repo.UpdateExistingCar(id, car2); //Assert Assert.IsTrue(UpdateResult); }
public void DeleteCar()//Delete a car from repo { //Arrange GasCar car = new GasCar("ford", "mustang", 2020); Car_Repo repo = new Car_Repo(); repo.AddCar(car); string id = "2020fordmustang"; //Act Car oldCar = repo.GetCarByID(id); bool removeResult = repo.DeleteCar(oldCar); //Assert Assert.IsTrue(removeResult); }
public void GetCarByID_ShouldReturnCorrectCar()//Read { //Arrange GasCar car = new GasCar("ford", "mustang", 2020); HybridCar car2 = new HybridCar("toyota", "prius", 2019); Car_Repo repo = new Car_Repo(); repo.AddCar(car); repo.AddCar(car2); string id = "2020fordmustang"; //Act var localCar = repo.GetCarByID(id); //assert Assert.AreEqual(localCar.CarID, id); }
public IActionResult Index(int ItemIdSelected) { Car temp = (Car)Car_Repo.GetAll().FirstOrDefault(x => x.Id == ItemIdSelected); return(EditCar(temp)); }