コード例 #1
0
ファイル: CarController.cs プロジェクト: JaminTc/Mystuff
        public ActionResult DeleteCar(int id)
        {
            DBCarRepository car = new DBCarRepository();
            car.DeleteCar(id);

            var cars = car.GetAllCars();
            return View("Index", cars);
        }
コード例 #2
0
ファイル: CarTests.cs プロジェクト: JaminTc/Mystuff
        public void TestDeleteRepo()
        {
            var _repo = new DBCarRepository();
            var car = _repo.GetAllCars().FirstOrDefault(x => x.Make == "Nissan" && x.Model == "Stanza" && x.Year == "1987");

            if (car != null)
            {
                //_repo.DeleteCar(car.Id);
            }
        }
コード例 #3
0
ファイル: CarController.cs プロジェクト: JaminTc/Mystuff
 public ActionResult AddNewCar(Car newCar)
 {
     ViewBag.Message = "Add a new Car!";
     if (ModelState.IsValid)
     {
         DBCarRepository car = new DBCarRepository();
         car.AddCar(newCar);
         return RedirectToAction("Index");
     }
     else
     {
         return View("Add");
     }
 }
コード例 #4
0
ファイル: CarTests.cs プロジェクト: JaminTc/Mystuff
        public void TestAddToRepo()
        {
            Car c = new Car()
            {
                Description = "Spam",
                Title = "Spam",
                Year = "1987",
                Make = "Nissan",
                Model = "Stanza",
                Price = 9999.00M,
                ImageUrl = "http://carphotos.cardomain.com/ride_images/1/1287/3601/3216800003_large.jpg"
            };

            var _repo = new DBCarRepository();
            _repo.AddCar(c);
        }
コード例 #5
0
ファイル: CarTests.cs プロジェクト: JaminTc/Mystuff
        public void TestEditRepo()
        {
            var _repo = new DBCarRepository();
            var car = _repo.GetAllCars().FirstOrDefault(x => x.Make == "Nissan" && x.Model == "Stanza" && x.Year == "1987");

            if (car != null)
            {
                Car c = new Car()
                {
                    Id = car.Id,
                    Description = "Well, well, well, what do we have here? A car with four doors? Check. A car with a solid roof? Check. A car with rearview mirrors so you can really connect with that Pearl Jam song? Psh, DOUBLE CHECK. We here at SWCG understand that your discriminating tastes demand that you're able to stand up to authority in style, and this 1987 Nissan Stanza virtually screams: \"Live free or die!\". Rest assured, the seat belts will help ensure that you can live free AND live. That's the SWCG guarentee. You're welcome. ",
                    Title = "PATRIOTIC Nissan Stanza from the year of our Lord 1987",
                    Year = "1987",
                    Make = "Nissan",
                    Model = "Stanza",
                    Price = 9999.00M,
                    ImageUrl = "http://carphotos.cardomain.com/ride_images/1/1287/3601/3216800003_large.jpg"
                };

                _repo.EditCar(c);
            }
        }
コード例 #6
0
ファイル: CarController.cs プロジェクト: JaminTc/Mystuff
 public ActionResult EditCar(Car editCar)
 {
     ViewBag.Message = "Edit your car!";
     if (ModelState.IsValid)
     {
         DBCarRepository car = new DBCarRepository();
         car.EditCar(editCar);
         return RedirectToAction("Index");
     }
     else
     {
         return View("Edit");
     }
 }