public List <CarList> GetCarList() { CarsEntities db = new CarsEntities(); List <CarList> cars = db.CarLists.ToList(); return(cars); }
public void AddCar(Car newCar) { CarsEntities ORM = new CarsEntities(); if (ModelState.IsValid) { ORM.Cars.Add(newCar); } }
public void DeleteCar(int ID) { CarsEntities ORM = new CarsEntities(); Car found = ORM.Cars.Find(ID); ORM.Cars.Remove(found); ORM.SaveChanges(); }
public ActionResult GetCarsByModel(string model) { CarsEntities db = new CarsEntities(); List <CarList> make1 = (from m in db.CarLists where m.Make.Contains(model) select m).ToList(); ViewBag.Makelist = make1; return(View("GetCarsByMake")); }
public ActionResult GetCarsByYear(int year) { CarsEntities db = new CarsEntities(); List <CarList> make1 = (from m in db.CarLists where m.Year == (year) select m).ToList(); ViewBag.Makelist = make1; return(View("GetCarsByMake")); }
public void EditCar(Car editCar) { CarsEntities ORM = new CarsEntities(); Car found = ORM.Cars.Find(editCar.CarID); found.Color = editCar.Color; found.Make = editCar.Model; found.Model = editCar.Model; ORM.Entry(found).State = System.Data.Entity.EntityState.Modified; //let them know it changed ORM.SaveChanges(); }
static void Main(string[] args) { using (CarsEntities db = new CarsEntities()) { List <Car> cars = db.Cars.Include(c => c.Model.Make).ToList(); foreach (Car item in cars) { Console.WriteLine(item.Model.Model1 + " " + item.Model.Make.Make1 + " " + item.Price); } } Console.ReadKey(); // BMW X5 RED $14000 2000 }
public Car GetCar(int id) { CarsEntities ORM = new CarsEntities(); return(ORM.Cars.Find(id)); }
public List <Car> GetCars() { CarsEntities ORM = new CarsEntities(); return(ORM.Cars.ToList()); }
public BaseRepository() { Context = new CarsEntities(); }