public ActionResult Create(ListViewModel model) { try { if (ModelState.IsValid) { vehicleModelService.CreateVehicleModel(AutoMapper.Mapper.Map <VehicleModel>(model)); return(RedirectToAction("VehicleModelList")); } } catch (DataException) { ModelState.AddModelError("", "Something went wrong! Can't create VehicleModel."); } return(RedirectToAction("Create")); }
public async Task ShouldCreateNewModel() { //Arrange var vehicleModel = new VehicleModel() { Id = 1, Name = "Car Model", Abrv = "CM", MakeId = 1 }; _modelRepoMock.Setup(x => x.Create(vehicleModel)).ReturnsAsync(true); //Act var result = await _sut.CreateVehicleModel(vehicleModel); //Assert result.Should().BeTrue(); }
public void CreateVehicleModel(int id, int makeId, string name, string abrv) { vehicleModelService.CreateVehicleModel(id, makeId, name, abrv); }