public ActionResult Edit(int id) { TireDataAccess tireDataAccess = new TireDataAccess(); TireModel model = tireDataAccess.Read(id); return(View(model)); }
public async Task <ActionResult> Register(TireModel model) { if (ModelState.IsValid) { TireDataAccess tireDataAccess = new TireDataAccess(); tireDataAccess.Create(model); return(RedirectToAction("List", "Tire")); } // If we got this far, something failed, redisplay form return(View(model)); }
public void CreateTest() { TireModel tireModel = new TireModel(); tireModel.Brand = "Brembo"; tireModel.Name = "Brembo"; tireModel.Size = "400 mm"; TireDataAccess tireDataAccess = new TireDataAccess(); tireDataAccess.Create(tireModel); Assert.IsNotNull(tireModel); }
public void DeleteTest() { TireDataAccess tireDataAccess = new TireDataAccess(); List <TireModel> tireList = tireDataAccess.List(); // This method will be executed after the CreateTest, so items should exist if (tireList == null || tireList.Count == 0) { Assert.Fail(); } TireModel model = tireList[0]; tireDataAccess.Delete(model.Id); model = tireDataAccess.Read(model.Id); Assert.IsNull(model); }
public void EditTest() { TireDataAccess tireDataAccess = new TireDataAccess(); List <TireModel> tireList = tireDataAccess.List(); // This method will be executed after the CreateTest, so items should exist if (tireList == null || tireList.Count == 0) { Assert.Fail(); } string newName = "New Name"; TireModel model = tireList[0]; model.Name = newName; tireDataAccess.Update(model); model = tireDataAccess.Read(model.Id); Assert.AreEqual(newName, model.Name); }