Пример #1
0
 public ActionResult Edit([Bind(Include = "ID,Name,ReleaseDate,Model,Price")] CarsModel carsModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carsModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carsModel));
 }
Пример #2
0
 public ActionResult Edit([Bind(Include = "ID,Year,Make,Model,Color")] Cars cars)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cars).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cars));
 }
Пример #3
0
        public async Task <ActionResult> PutCars(int id, Cars updatedCars)
        {
            if (id != updatedCars.Id || !ModelState.IsValid)
            {
                return(BadRequest());
            }
            else
            {
                _context.Entry(updatedCars).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
        }
Пример #4
0
        public async Task <IActionResult> ChangeCars(int id, string make, string model, string color, int year)
        {
            List <Cars> cars = await CD.GetCars();

            Cars found = _context.Cars.Find(id);

            if (found != null)
            {
                found.Make  = make;
                found.Model = model;
                found.Year  = year;
                found.Color = color;

                _context.Entry(found).State = EntityState.Modified;
                _context.Update(found);
                await _context.SaveChangesAsync();

                CD.UpdateCar(id, found);
            }
            return(RedirectToAction("Index", cars));
        }