Example #1
0
        public void CanRemoveCar()
        {
            var repo = new CarsRepository();

            Assert.AreEqual(6, repo.GetAll().Count);
            repo.Remove(1);
            Assert.AreEqual(5, repo.GetAll().Count);
        }
Example #2
0
        public void CanAddCars()
        {
            var repo = new CarsRepository();

            Assert.AreEqual(6, repo.GetAll().Count);
            repo.Add(new Cars()
            {
                AspNetUserId = "*****@*****.**", BodyStyleId = 1, CarModelId = 1, CarTypeId = 1, CarYear = 1992, ColorId = 1, Discription = "Good car", InteriorColorId = 1, Mileage = 20000, MSRP = 2, SalesPrice = 20000, Special = true, TransmissionId = 1, Vin = 8
            });
            Assert.AreEqual(7, repo.GetAll().Count);
        }
Example #3
0
        // GET: Car
        public ActionResult Edit()
        {
            CarsRepository repo = new CarsRepository();

            CarViewModel model = new CarViewModel(repo.GetAll());

            return(View(model));
        }
Example #4
0
        public ActionResult Index()
        {
            CarsRepository repo  = new CarsRepository();
            List <Car>     items = repo.GetAll();

            ViewData["cars"] = items;
            return(View());
        }
Example #5
0
        public ActionResult Index()
        {
            var cars = repo.GetAll();

            var carViews = cars.Select(car => new CarViewModel(car.ID, car.HorsePower, car.Color, car.Year, car.Models,
                                                               new OwnerViewModel(car.User))).ToList();

            return(View(carViews));
        }
Example #6
0
        public void GetCarFromDBTest()
        {
            //Arrange
            var            context = new AuctionDbContext("DefaultConnection");
            var            db      = context;
            CarsRepository tmp     = new CarsRepository(context);

            Assert.AreEqual(tmp.GetAll(), db.Cars);
        }
        // GET: Cars
        public ActionResult Cars()
        {
            AdvertRepository       advertRepository   = new AdvertRepository();
            CarsRepository         carsRepository     = new CarsRepository();
            CarPhotoRepository     carPhotoRepository = new CarPhotoRepository();
            List <AdvertViewModel> advertViews        = new List <AdvertViewModel>();
            var result       = carsRepository.GetAll();
            var resultadvert = advertRepository.GetAll();

            foreach (var item in result)
            {
                advertViews.Add(new AdvertViewModel {
                    Carss = item,
                    Photo = carPhotoRepository.GetByFilterx(x => x.CarId == item.Id).Photo
                });
            }
            foreach (var item in resultadvert)
            {
                advertViews.ForEach(x => x.Adverts = item);
            }

            return(View(advertViews));
        }
Example #8
0
 //SECTION Get cars
 internal IEnumerable <Car> GetAll()
 {
     return(_repo.GetAll());
 }
Example #9
0
        public void CanGetAllCars()
        {
            var repo = new CarsRepository();

            Assert.AreEqual(6, repo.GetAll().Count);
        }