Exemplo n.º 1
0
        public IActionResult Edit(string id)
        {
            var carToEdit = logic.GetAll()
                            .FirstOrDefault(t => t.Id == id);

            return(View(carToEdit));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // add connection string
            // add entity fw

            CarDatabaseEntities db = new CarDatabaseEntities();

            Console.WriteLine(db.CAR.Count());

            //var q = from car in db.CAR
            //        group car by car.BRAND into grp
            //        select new
            //        {
            //            Brand = grp.Key.brand_name,
            //            AvgPrice = grp.Average(car => car.car_baseprice)
            //        };

            //foreach (var item in q) Console.WriteLine(item);


            // ----


            CarLogic cl = new CarLogic();

            Console.WriteLine("----");
            foreach (var item in cl.GetBrandAverages())
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("----");
            foreach (var item in cl.GetCarsWithLetter('a', false))
            {
                Console.WriteLine(item);
            }

            cl.InsertCar(new CAR()
            {
                car_model         = "Ford mustang",
                car_baseprice     = 990,
                car_discountprice = 10,
                car_brand         = 1,
                car_id            = 5 // no identity ~ auto incr.
            });

            cl.DeleteCar(1);

            Console.WriteLine("----");
            foreach (var item in cl.GetAll())
            {
                Console.WriteLine($"{item.car_model} {item.car_baseprice} {item.car_discountprice}");
            }

            Console.WriteLine("----");
            Console.WriteLine(cl.GetCheapestCarModel());
        }
Exemplo n.º 3
0
        private void btnAddCar_Click(object sender, EventArgs e)
        {
            string TextMark = textMark.Text;


            if (!String.IsNullOrEmpty(TextMark))
            {
                _carLogic.Add(new Car
                {
                    Mark = TextMark,
                });

                var car = _carLogic.GetAll();

                if (car == null)
                {
                    return;
                }

                GridViewCar(car);
            }
        }
Exemplo n.º 4
0
 public AdminCarWindow()
 {
     InitializeComponent();
     CarTable.DataSource = carLogic.GetAll();
 }