public async Task CalculateTotalPurchasePriceTest() { var car = CarDataSeeder.GetEntities().First(); await _carRepository.AddAsync(car); var carModel = (await _carModelService.GetCarModelsAsync()).Last(); Assert.Equal(1100, _carModelService.CalculateTotalPurchasePrice(carModel)); }
public async Task <IActionResult> AddCar(CarModel carModel) { if (carModel.SellingPrice <= _carModelService.CalculateTotalPurchasePrice(carModel)) { ModelState.AddModelError("", "Car Price is smaller than Purchase Price and Repair costs (must be bigger when adding a new car)!"); return(View(carModel)); } return(await SaveCar(carModel, "Overview")); }