public async Task Delete(int ID) { var weapon = _weaponRepository.GetById(ID); if (weapon == null) { throw new WeaponNotFoundException("Weapon matching ID not found."); } // Delete and save _weaponRepository.Delete(weapon); await _weaponRepository.SaveChanges(); }
public ActionResult Delete(Weapon weapon) { weaponRepository = new WeaponRepository(); weaponRepository.Delete(weapon.ID); return(RedirectToAction("Weapons")); }