Ejemplo n.º 1
0
 public void Delete(TEntity obj, bool saveChanges = true)
 {
     dbContext.Remove(obj);
     if (saveChanges)
     {
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 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..."));
            }
        }
Ejemplo n.º 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..."));
            }
        }
Ejemplo n.º 4
0
        public void Delete(int id)
        {
            Hero hero = _context.hero.Where(h => h.Id == id).FirstOrDefault();

            _context.Remove(hero);
        }
Ejemplo n.º 5
0
        public virtual void Delete(T entity)
        {
            _context.Remove(entity);

            Save();
        }