示例#1
0
 public void Delete(TEntity obj, bool saveChanges = true)
 {
     dbContext.Remove(obj);
     if (saveChanges)
     {
         dbContext.SaveChanges();
     }
 }
示例#2
0
// ---------------------------------------------------------------------
        public IActionResult DeleteVillain(int villainID)
        {
            VillainsModel foundVillain = _context.villains.FirstOrDefault(v => v.id == villainID);

            if (foundVillain != null)
            {
                _context.Remove(foundVillain);
                _context.SaveChanges();
                return(RedirectToAction("DisplayAllVillains"));
            }
            else
            {
                return(Content($"Someone is trying to erase our memories..."));
            }
        }
示例#3
0
// ---------------------------------------------------------------------
        public IActionResult DeleteHero(int heroID)
        {
            HeroesModel foundHero = _context.heroes.FirstOrDefault(h => h.id == heroID);

            if (foundHero != null)
            {
                _context.Remove(foundHero);
                _context.SaveChanges();
                return(RedirectToAction("DisplayAllHeroes"));
            }
            else
            {
                return(Content($"Someone is trying to erase our memories..."));
            }
        }
示例#4
0
        public void Delete(int id)
        {
            Hero hero = _context.hero.Where(h => h.Id == id).FirstOrDefault();

            _context.Remove(hero);
        }
示例#5
0
        public virtual void Delete(T entity)
        {
            _context.Remove(entity);

            Save();
        }