コード例 #1
0
        public List <CarList> GetCarList()
        {
            CarsEntities db = new CarsEntities();

            List <CarList> cars = db.CarLists.ToList();

            return(cars);
        }
コード例 #2
0
        public void AddCar(Car newCar)
        {
            CarsEntities ORM = new CarsEntities();

            if (ModelState.IsValid)
            {
                ORM.Cars.Add(newCar);
            }
        }
コード例 #3
0
        public void DeleteCar(int ID)
        {
            CarsEntities ORM = new CarsEntities();

            Car found = ORM.Cars.Find(ID);

            ORM.Cars.Remove(found);
            ORM.SaveChanges();
        }
コード例 #4
0
        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"));
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
        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();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: sergiusanduta/project
        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
        }
コード例 #8
0
        public Car GetCar(int id)
        {
            CarsEntities ORM = new CarsEntities();

            return(ORM.Cars.Find(id));
        }
コード例 #9
0
        public List <Car> GetCars()
        {
            CarsEntities ORM = new CarsEntities();

            return(ORM.Cars.ToList());
        }
コード例 #10
0
 public BaseRepository()
 {
     Context = new CarsEntities();
 }