public IActionResult Delete(int id)
        {
            var make = mDbContext.Makes.Find(id);

            if (make == null)
            {
                return(NotFound());
            }

            mDbContext.Remove(make);
            mDbContext.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }
Beispiel #2
0
        public IActionResult Delete(int id)
        {
            var brand = _context.Brands.Find(id);

            if (brand != null)
            {
                _context.Remove(brand);
                _context.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(NotFound());
        }
        [HttpPost]                          // HH: we do delete via post, NOT GET!!!
        public IActionResult Delete(int id) // HH: model id
        {
            //Model model = mDbContext.Models.Where(model => model.Id == id).FirstOrDefault(); ;
            Model model = mDbContext.Models.Find(id);

            if (model == null)
            {
                return(NotFound());
            }

            mDbContext.Remove(model);
            mDbContext.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }