Beispiel #1
0
        public ActionResult Index(Guid?locationId)
        {
            using (var storeRepo = new StoreLocationRepo(this.db))
                using (var carRepo = new CarRepository(this.db))
                {
                    List <Car>    validCars;
                    StoreLocation store;

                    if (locationId.HasValue)
                    {
                        store     = storeRepo.GetStoreById(locationId.Value);
                        validCars = carRepo.CarsByLocationId(locationId.Value, c => c.Manufacturer).ToList();
                    }
                    else
                    {
                        store     = null;
                        validCars = carRepo.AllCars(c => c.Manufacturer).ToList();
                    }

                    var model = new CarIndexViewModel {
                        Cars = validCars, selectedLocation = store
                    };

                    return(View("~/Views/Car/Index.cshtml", model));
                }
        }
Beispiel #2
0
 public IEnumerable <Car> GetAllCars()
 {
     using (var carRepo = new CarRepository(this.context))
     {
         return(carRepo.AllCars(c => c.Manufacturer).ToList());
     }
 }