Example #1
0
        public ActionResult Edit(int id)
        {
            TireDataAccess tireDataAccess = new TireDataAccess();
            TireModel      model          = tireDataAccess.Read(id);

            return(View(model));
        }
Example #2
0
        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));
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }