public void DeleteCompany(Company company) { if (company == null) { throw new ArgumentNullException(nameof(company)); } _db.Remove(company); }
public IActionResult Delete(int id) { var nv = _context.Employees.Where(s => s.Id == id).FirstOrDefault(); _context.Remove(nv); _context.SaveChanges(); return(Ok("Xóa nhân viên thành công!")); }
public async Task <IActionResult> RemoveBook(int id) { var book = await _Context.Books.Where(a => a.id == id).SingleOrDefaultAsync(); _Context.Remove(book); await _Context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task DeleteAsync(CustomerViewModel vm) { var entity = _context.Customers.FirstOrDefault(item => item.Id == vm.Id); if (entity != null) { _context.Remove(entity); await _context.SaveChangesAsync(); } }
/// </inheritdoc> public async Task DeleteItemAsync(int id) { var item = await _context.Items.FindAsync(id); if (item == null) { throw new NotFoundException($"Item with {nameof(id)}: {id} not found"); } _context.Remove(item); await _context.SaveChangesAsync(); }
/// <summary> /// Deletes a contact /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task DeleteContact(int id) { try { var contact = await _demoContext.Contacts.FirstOrDefaultAsync(v => v.ContactId == id); _demoContext.Remove(contact); await _demoContext.SaveChangesAsync(); } catch (Exception) { throw; } }