Exemple #1
0
        public void UpdateName(int id, string newName)
        {
            var car = GetOne(id);

            car.car_model = newName;
            db.SaveChanges();
        }
Exemple #2
0
        // GET: /Home/Delete/{id}
        public ActionResult Delete(int id)
        {
            var car = (from c in _db.CarTable where c.Id == id select c).First();

            _db.CarTable.Remove(car);
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Phone,Mail,Adress")] customer customer)
        {
            if (ModelState.IsValid)
            {
                db.customer.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "Id,Matricule,Datesold,Name,Price")] carsold carsold)
        {
            if (ModelState.IsValid)
            {
                db.carsold.Add(carsold);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(carsold));
        }
Exemple #5
0
        public ActionResult Create([Bind(Include = "Id,Matricule,Categories,Puissance,Date,Name,Price,Image,url_image")] car car)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0)
                {
                    var file = Request.Files[0];
                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/Fichier"), fileName);
                        file.SaveAs(path);
                        car.Image     = fileName;
                        car.url_image = "/Fichier";
                    }
                }
                // car.Date = DateTime.Now;
                db.car.Add(car);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(car));
        }