Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Model,Motor,EngineType,Year,Price,ManufacturerId,CarDealerId")] Car car)
        {
            if (id != car.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(car);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarExists(car.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarDealerId"]    = new SelectList(_context.CarDealers, "Id", "Id", car.CarDealerId);
            ViewData["ManufacturerId"] = new SelectList(_context.Manufacturers, "Id", "Id", car.ManufacturerId);
            return(View(car));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] CarDealer carDealer)
        {
            if (id != carDealer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(carDealer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarDealerExists(carDealer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(carDealer));
        }
Example #3
0
        public IActionResult EditPost()
        {
            if (!ModelState.IsValid)
            {
                return(View(ModelVM));
            }

            _db.Update(ModelVM.Model);
            _db.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }
Example #4
0
        public IActionResult Edit(Make make)
        {
            if (ModelState.IsValid)
            {
                _db.Update(make);
                _db.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }

            return(View(make));
        }