public void Update_ShouldUpdateItem( int id, string chassis, EnumModelViewModel model, int year, int modelYear) { // Arrange var truckViewModel = new TruckViewModel { Id = id, Chassis = chassis, Model = model, Year = year, ModelYear = modelYear }; // Act TruckService.Update(truckViewModel); var truck = FakeUnitOfWork.TruckRepository.GetAll(t => t.Chassis.Equals(chassis)).FirstOrDefault(); // Assert Assert.AreEqual(chassis, truck.Chassis, "Item was not updated"); }
public ActionResult Edit(int id, TruckViewModel truckViewModel) { try { if (ModelState.IsValid) { TruckService.Update(truckViewModel); return(RedirectToAction(nameof(Index))); } return(View(truckViewModel)); } catch (Exception ex) { Logger.LogError(ex, ex.Message); return(View(truckViewModel)); } }